victory-core 36.3.2 → 36.5.0
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/dist/victory-core.js +15084 -15018
- package/dist/victory-core.min.js +1 -1
- package/es/index.d.ts +38 -941
- package/es/index.js +19 -28
- package/es/types.d.ts +33 -0
- package/es/types.js +1 -0
- package/es/victory-accessible-group/victory-accessible-group.d.ts +25 -0
- package/es/victory-accessible-group/victory-accessible-group.js +35 -45
- package/es/victory-animation/util.d.ts +66 -0
- package/es/victory-animation/util.js +3 -2
- package/es/victory-animation/victory-animation.d.ts +69 -0
- package/es/victory-animation/victory-animation.js +92 -102
- package/es/victory-clip-container/victory-clip-container.d.ts +76 -0
- package/es/victory-clip-container/victory-clip-container.js +75 -82
- package/es/victory-container/victory-container.d.ts +99 -0
- package/es/victory-container/victory-container.js +97 -107
- package/es/victory-label/victory-label.d.ts +61 -0
- package/es/victory-label/victory-label.js +43 -31
- package/es/victory-portal/portal-context.d.ts +11 -0
- package/es/victory-portal/portal-context.js +3 -4
- package/es/victory-portal/portal.d.ts +28 -0
- package/es/victory-portal/portal.js +44 -50
- package/es/victory-portal/victory-portal.d.ts +31 -0
- package/es/victory-portal/victory-portal.js +38 -47
- package/es/victory-primitives/arc.d.ts +21 -0
- package/es/victory-primitives/arc.js +9 -9
- package/es/victory-primitives/background.d.ts +22 -0
- package/es/victory-primitives/background.js +12 -12
- package/es/victory-primitives/border.d.ts +18 -0
- package/es/victory-primitives/border.js +9 -9
- package/es/victory-primitives/circle.d.ts +2 -0
- package/es/victory-primitives/circle.js +17 -10
- package/es/victory-primitives/clip-path.d.ts +14 -0
- package/es/victory-primitives/clip-path.js +6 -6
- package/es/victory-primitives/index.d.ts +14 -0
- package/es/victory-primitives/index.js +14 -0
- package/es/victory-primitives/line-segment.d.ts +19 -0
- package/es/victory-primitives/line-segment.js +9 -9
- package/es/victory-primitives/line.d.ts +2 -0
- package/es/victory-primitives/line.js +17 -10
- package/es/victory-primitives/path.d.ts +2 -0
- package/es/victory-primitives/path.js +15 -8
- package/es/victory-primitives/point.d.ts +21 -0
- package/es/victory-primitives/point.js +15 -23
- package/es/victory-primitives/rect.d.ts +2 -0
- package/es/victory-primitives/rect.js +17 -10
- package/es/victory-primitives/text.d.ts +16 -0
- package/es/victory-primitives/text.js +13 -8
- package/es/victory-primitives/tspan.d.ts +2 -0
- package/es/victory-primitives/tspan.js +7 -6
- package/es/victory-primitives/types.d.ts +7 -0
- package/es/victory-primitives/types.js +1 -0
- package/es/victory-primitives/whisker.d.ts +24 -0
- package/es/victory-primitives/whisker.js +12 -12
- package/es/victory-theme/grayscale.d.ts +2 -0
- package/es/victory-theme/grayscale.js +1 -1
- package/es/victory-theme/material.d.ts +2 -0
- package/es/victory-theme/material.js +1 -1
- package/es/victory-theme/victory-theme-definition.d.ts +244 -0
- package/es/victory-theme/victory-theme-definition.js +1 -0
- package/es/victory-theme/victory-theme.d.ts +5 -0
- package/es/victory-theme/victory-theme.js +6 -5
- package/es/victory-transition/victory-transition.d.ts +59 -0
- package/es/victory-transition/victory-transition.js +38 -44
- package/es/victory-util/add-events.js +328 -319
- package/es/victory-util/axis.js +12 -6
- package/es/victory-util/collection.js +7 -5
- package/es/victory-util/common-props.js +2 -2
- package/es/victory-util/data.js +8 -6
- package/es/victory-util/default-transitions.js +0 -1
- package/es/victory-util/domain.js +7 -5
- package/es/victory-util/events.js +8 -4
- package/es/victory-util/helpers.js +1 -3
- package/es/victory-util/hooks/use-animation-state.js +11 -5
- package/es/victory-util/immutable.js +0 -1
- package/es/victory-util/label-helpers.js +0 -2
- package/es/victory-util/line-helpers.js +1 -1
- package/es/victory-util/log.js +0 -1
- package/es/victory-util/point-path-helpers.d.ts +9 -0
- package/es/victory-util/point-path-helpers.js +59 -61
- package/es/victory-util/scale.js +19 -19
- package/es/victory-util/selection.d.ts +23 -0
- package/es/victory-util/selection.js +0 -2
- package/es/victory-util/style.js +0 -2
- package/es/victory-util/textsize.d.ts +8 -0
- package/es/victory-util/textsize.js +11 -7
- package/es/victory-util/timer-context.d.ts +11 -0
- package/es/victory-util/timer-context.js +1 -1
- package/es/victory-util/timer.d.ts +16 -0
- package/es/victory-util/timer.js +16 -13
- package/es/victory-util/types.d.ts +188 -0
- package/es/victory-util/types.js +1 -0
- package/es/victory-util/user-props.js +44 -4
- package/es/victory-util/wrapper.js +18 -12
- package/lib/index.d.ts +38 -941
- package/lib/index.js +201 -189
- package/lib/types.d.ts +33 -0
- package/lib/types.js +1 -0
- package/lib/victory-accessible-group/victory-accessible-group.d.ts +25 -0
- package/lib/victory-accessible-group/victory-accessible-group.js +37 -45
- package/lib/victory-animation/util.d.ts +66 -0
- package/lib/victory-animation/util.js +4 -3
- package/lib/victory-animation/victory-animation.d.ts +69 -0
- package/lib/victory-animation/victory-animation.js +97 -102
- package/lib/victory-clip-container/victory-clip-container.d.ts +76 -0
- package/lib/victory-clip-container/victory-clip-container.js +81 -82
- package/lib/victory-container/victory-container.d.ts +99 -0
- package/lib/victory-container/victory-container.js +102 -107
- package/lib/victory-label/victory-label.d.ts +61 -0
- package/lib/victory-label/victory-label.js +49 -32
- package/lib/victory-portal/portal-context.d.ts +11 -0
- package/lib/victory-portal/portal-context.js +4 -5
- package/lib/victory-portal/portal.d.ts +28 -0
- package/lib/victory-portal/portal.js +49 -50
- package/lib/victory-portal/victory-portal.d.ts +31 -0
- package/lib/victory-portal/victory-portal.js +43 -47
- package/lib/victory-primitives/arc.d.ts +21 -0
- package/lib/victory-primitives/arc.js +13 -10
- package/lib/victory-primitives/background.d.ts +22 -0
- package/lib/victory-primitives/background.js +16 -13
- package/lib/victory-primitives/border.d.ts +18 -0
- package/lib/victory-primitives/border.js +13 -10
- package/lib/victory-primitives/circle.d.ts +2 -0
- package/lib/victory-primitives/circle.js +17 -8
- package/lib/victory-primitives/clip-path.d.ts +14 -0
- package/lib/victory-primitives/clip-path.js +7 -5
- package/lib/victory-primitives/index.d.ts +14 -0
- package/lib/victory-primitives/index.js +187 -0
- package/lib/victory-primitives/line-segment.d.ts +19 -0
- package/lib/victory-primitives/line-segment.js +13 -10
- package/lib/victory-primitives/line.d.ts +2 -0
- package/lib/victory-primitives/line.js +17 -8
- package/lib/victory-primitives/path.d.ts +2 -0
- package/lib/victory-primitives/path.js +15 -6
- package/lib/victory-primitives/point.d.ts +21 -0
- package/lib/victory-primitives/point.js +21 -25
- package/lib/victory-primitives/rect.d.ts +2 -0
- package/lib/victory-primitives/rect.js +17 -8
- package/lib/victory-primitives/text.d.ts +16 -0
- package/lib/victory-primitives/text.js +14 -7
- package/lib/victory-primitives/tspan.d.ts +2 -0
- package/lib/victory-primitives/tspan.js +7 -4
- package/lib/victory-primitives/types.d.ts +7 -0
- package/lib/victory-primitives/types.js +1 -0
- package/lib/victory-primitives/whisker.d.ts +24 -0
- package/lib/victory-primitives/whisker.js +16 -13
- package/lib/victory-theme/grayscale.d.ts +2 -0
- package/lib/victory-theme/grayscale.js +3 -3
- package/lib/victory-theme/material.d.ts +2 -0
- package/lib/victory-theme/material.js +3 -3
- package/lib/victory-theme/victory-theme-definition.d.ts +244 -0
- package/lib/victory-theme/victory-theme-definition.js +1 -0
- package/lib/victory-theme/victory-theme.d.ts +5 -0
- package/lib/victory-theme/victory-theme.js +22 -8
- package/lib/victory-transition/victory-transition.d.ts +59 -0
- package/lib/victory-transition/victory-transition.js +43 -45
- package/lib/victory-util/add-events.js +326 -316
- package/lib/victory-util/axis.js +20 -11
- package/lib/victory-util/collection.js +10 -8
- package/lib/victory-util/common-props.js +6 -4
- package/lib/victory-util/data.js +13 -7
- package/lib/victory-util/default-transitions.js +1 -2
- package/lib/victory-util/domain.js +11 -5
- package/lib/victory-util/events.js +17 -11
- package/lib/victory-util/helpers.js +14 -16
- package/lib/victory-util/hooks/index.js +4 -4
- package/lib/victory-util/hooks/use-animation-state.js +14 -6
- package/lib/victory-util/immutable.js +3 -5
- package/lib/victory-util/label-helpers.js +6 -6
- package/lib/victory-util/line-helpers.js +4 -2
- package/lib/victory-util/log.js +0 -1
- package/lib/victory-util/point-path-helpers.d.ts +9 -0
- package/lib/victory-util/point-path-helpers.js +86 -73
- package/lib/victory-util/prop-types.js +5 -3
- package/lib/victory-util/scale.js +24 -21
- package/lib/victory-util/selection.d.ts +23 -0
- package/lib/victory-util/selection.js +5 -5
- package/lib/victory-util/style.js +0 -2
- package/lib/victory-util/textsize.d.ts +8 -0
- package/lib/victory-util/textsize.js +12 -8
- package/lib/victory-util/timer-context.d.ts +11 -0
- package/lib/victory-util/timer-context.js +1 -1
- package/lib/victory-util/timer.d.ts +16 -0
- package/lib/victory-util/timer.js +16 -13
- package/lib/victory-util/types.d.ts +188 -0
- package/lib/victory-util/types.js +1 -0
- package/lib/victory-util/user-props.js +53 -6
- package/lib/victory-util/wrapper.js +31 -23
- package/package.json +6 -13
- package/src/index.ts +42 -0
- package/src/types.ts +45 -0
- package/src/victory-accessible-group/{victory-accessible-group.js → victory-accessible-group.tsx} +10 -3
- package/src/victory-animation/{util.js → util.ts} +5 -4
- package/src/victory-animation/{victory-animation.js → victory-animation.tsx} +90 -13
- package/src/victory-clip-container/{victory-clip-container.js → victory-clip-container.tsx} +32 -6
- package/src/victory-container/{victory-container.js → victory-container.tsx} +70 -26
- package/src/victory-label/{victory-label.js → victory-label.tsx} +80 -19
- package/src/victory-portal/portal-context.ts +14 -0
- package/src/victory-portal/{portal.js → portal.tsx} +23 -12
- package/src/victory-portal/{victory-portal.js → victory-portal.tsx} +21 -6
- package/src/victory-primitives/{arc.js → arc.tsx} +15 -5
- package/src/victory-primitives/{background.js → background.tsx} +17 -7
- package/src/victory-primitives/{border.js → border.tsx} +12 -5
- package/src/victory-primitives/{circle.js → circle.tsx} +4 -3
- package/src/victory-primitives/clip-path.tsx +25 -0
- package/src/victory-primitives/index.ts +14 -0
- package/src/victory-primitives/{line-segment.js → line-segment.tsx} +13 -5
- package/src/victory-primitives/{line.js → line.tsx} +4 -3
- package/src/victory-primitives/{path.js → path.tsx} +4 -3
- package/src/victory-primitives/{point.js → point.tsx} +25 -20
- package/src/victory-primitives/{rect.js → rect.tsx} +4 -2
- package/src/victory-primitives/{text.js → text.tsx} +9 -3
- package/src/victory-primitives/tspan.tsx +7 -0
- package/src/victory-primitives/types.ts +19 -0
- package/src/victory-primitives/{whisker.js → whisker.tsx} +20 -7
- package/src/victory-theme/{grayscale.js → grayscale.tsx} +2 -1
- package/src/victory-theme/{material.js → material.tsx} +2 -1
- package/src/victory-theme/victory-theme-definition.ts +261 -0
- package/src/victory-theme/victory-theme.tsx +5 -0
- package/src/victory-transition/{victory-transition.js → victory-transition.tsx} +68 -19
- package/src/victory-util/add-events.js +7 -5
- package/src/victory-util/axis.js +3 -1
- package/src/victory-util/collection.js +0 -1
- package/src/victory-util/common-props.js +2 -2
- package/src/victory-util/data.js +0 -1
- package/src/victory-util/default-transitions.js +0 -1
- package/src/victory-util/domain.js +0 -1
- package/src/victory-util/events.js +1 -1
- package/src/victory-util/helpers.js +0 -1
- package/src/victory-util/immutable.js +0 -1
- package/src/victory-util/label-helpers.js +0 -1
- package/src/victory-util/line-helpers.js +1 -1
- package/src/victory-util/log.js +0 -1
- package/src/victory-util/point-path-helpers.ts +119 -0
- package/src/victory-util/prop-types.js +0 -1
- package/src/victory-util/scale.js +18 -10
- package/src/victory-util/selection.d.ts +23 -0
- package/src/victory-util/selection.js +0 -1
- package/src/victory-util/style.js +0 -1
- package/src/victory-util/textsize.d.ts +8 -0
- package/src/victory-util/{timer-context.js → timer-context.ts} +0 -0
- package/src/victory-util/{timer.js → timer.ts} +20 -5
- package/src/victory-util/transitions.js +0 -1
- package/src/victory-util/types.ts +247 -0
- package/src/victory-util/user-props.js +31 -1
- package/src/victory-util/wrapper.js +0 -1
- package/src/index.d.ts +0 -941
- package/src/index.js +0 -51
- package/src/victory-portal/portal-context.js +0 -10
- package/src/victory-primitives/clip-path.js +0 -18
- package/src/victory-primitives/tspan.js +0 -5
- package/src/victory-theme/victory-theme.js +0 -7
- package/src/victory-util/point-path-helpers.js +0 -121
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/* eslint-disable func-style */
|
|
2
1
|
/* eslint-disable no-use-before-define */
|
|
3
2
|
import { includes, isFunction, isPlainObject } from "lodash";
|
|
4
3
|
import * as Helpers from "./helpers";
|
|
5
4
|
import * as Collection from "./collection";
|
|
6
|
-
import * as d3Scale from "d3-scale";
|
|
5
|
+
import * as d3Scale from "victory-vendor/d3-scale";
|
|
7
6
|
|
|
8
7
|
const supportedScaleStrings = ["linear", "time", "log", "sqrt"];
|
|
9
8
|
|
|
@@ -110,19 +109,28 @@ export function getScaleType(props, axis) {
|
|
|
110
109
|
);
|
|
111
110
|
}
|
|
112
111
|
|
|
112
|
+
// Ordered type inference off of function fields.
|
|
113
|
+
// **Note**: Brittle because reliant on d3 internals.
|
|
114
|
+
const DUCK_TYPES = [
|
|
115
|
+
{ name: "quantile", method: "quantiles" },
|
|
116
|
+
{ name: "log", method: "base" }
|
|
117
|
+
// TODO(2214): Re-evaluate (1) duck typing approach, and (2) if duck typing,
|
|
118
|
+
// do we need a different approach? (Multiple keys? Stringifying functions?)
|
|
119
|
+
// https://github.com/FormidableLabs/victory/issues/2214
|
|
120
|
+
// Below are matches that don't seem to otherwise occur in Victory code base.
|
|
121
|
+
// { name: "ordinal", method: "unknown" },
|
|
122
|
+
// { name: "pow-sqrt", method: "exponent" },
|
|
123
|
+
// { name: "quantize-threshold", method: "invertExtent" }
|
|
124
|
+
];
|
|
125
|
+
|
|
113
126
|
export function getType(scale) {
|
|
114
127
|
if (typeof scale === "string") {
|
|
115
128
|
return scale;
|
|
116
129
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
{ name: "ordinal", method: "unknown" },
|
|
120
|
-
{ name: "pow-sqrt", method: "exponent" },
|
|
121
|
-
{ name: "quantile", method: "quantiles" },
|
|
122
|
-
{ name: "quantize-threshold", method: "invertExtent" }
|
|
123
|
-
];
|
|
124
|
-
const scaleType = duckTypes.filter((type) => {
|
|
130
|
+
|
|
131
|
+
const scaleType = DUCK_TYPES.filter((type) => {
|
|
125
132
|
return scale[type.method] !== undefined;
|
|
126
133
|
})[0];
|
|
134
|
+
|
|
127
135
|
return scaleType ? scaleType.name : undefined;
|
|
128
136
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DomainPropType, ScalePropType, SVGCoordinateType } from "./types";
|
|
3
|
+
|
|
4
|
+
export function getParentSVG(evt: React.SyntheticEvent): string;
|
|
5
|
+
|
|
6
|
+
export function getSVGEventCoordinates(
|
|
7
|
+
evt: React.SyntheticEvent,
|
|
8
|
+
svg?: SVGElement
|
|
9
|
+
): SVGCoordinateType;
|
|
10
|
+
|
|
11
|
+
export function getDomainCoordinates(
|
|
12
|
+
props: any,
|
|
13
|
+
domain?: DomainPropType
|
|
14
|
+
): DomainPropType;
|
|
15
|
+
|
|
16
|
+
export function getDataCoordinates(
|
|
17
|
+
props: any,
|
|
18
|
+
scale: ScalePropType,
|
|
19
|
+
x: number,
|
|
20
|
+
y: number
|
|
21
|
+
): SVGCoordinateType;
|
|
22
|
+
|
|
23
|
+
export function getBounds(props: any): SVGCoordinateType;
|
|
File without changes
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
import { timer, now } from "d3-timer";
|
|
1
|
+
import { timer, now } from "victory-vendor/d3-timer";
|
|
2
|
+
|
|
3
|
+
interface D3Timer {
|
|
4
|
+
new (callback): void;
|
|
5
|
+
stop(): void;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type Callback = (elapsed: number, duration: number) => void;
|
|
2
9
|
|
|
3
10
|
export default class Timer {
|
|
11
|
+
private shouldAnimate: boolean;
|
|
12
|
+
private readonly subscribers: Array<{
|
|
13
|
+
callback: Callback;
|
|
14
|
+
startTime: number;
|
|
15
|
+
duration: number;
|
|
16
|
+
}>;
|
|
17
|
+
private activeSubscriptions: number;
|
|
18
|
+
private timer: D3Timer | null;
|
|
19
|
+
|
|
4
20
|
constructor() {
|
|
5
21
|
this.shouldAnimate = true;
|
|
6
22
|
this.subscribers = [];
|
|
7
|
-
this.loop = this.loop.bind(this);
|
|
8
23
|
this.timer = null;
|
|
9
24
|
this.activeSubscriptions = 0;
|
|
10
25
|
}
|
|
@@ -17,11 +32,11 @@ export default class Timer {
|
|
|
17
32
|
this.shouldAnimate = true;
|
|
18
33
|
}
|
|
19
34
|
|
|
20
|
-
loop() {
|
|
35
|
+
loop = () => {
|
|
21
36
|
this.subscribers.forEach((s) => {
|
|
22
37
|
s.callback(now() - s.startTime, s.duration);
|
|
23
38
|
});
|
|
24
|
-
}
|
|
39
|
+
};
|
|
25
40
|
|
|
26
41
|
start() {
|
|
27
42
|
if (!this.timer) {
|
|
@@ -36,7 +51,7 @@ export default class Timer {
|
|
|
36
51
|
}
|
|
37
52
|
}
|
|
38
53
|
|
|
39
|
-
subscribe(callback, duration) {
|
|
54
|
+
subscribe(callback: Callback, duration: number) {
|
|
40
55
|
duration = this.shouldAnimate ? duration : 0;
|
|
41
56
|
const subscriptionID = this.subscribers.push({
|
|
42
57
|
startTime: now(),
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { OriginType } from "../victory-label/victory-label";
|
|
3
|
+
import {
|
|
4
|
+
NumberOrCallback,
|
|
5
|
+
PaddingProps,
|
|
6
|
+
VictoryThemeDefinition
|
|
7
|
+
} from "../victory-theme/victory-theme";
|
|
8
|
+
import { StringOrCallback, StringOrNumberOrCallback } from "../types";
|
|
9
|
+
import {
|
|
10
|
+
AnimationEasing,
|
|
11
|
+
AnimationStyle
|
|
12
|
+
} from "../victory-animation/victory-animation";
|
|
13
|
+
|
|
14
|
+
export type StringOrNumberOrList = string | number | (string | number)[];
|
|
15
|
+
|
|
16
|
+
export interface AnimatePropTypeInterface {
|
|
17
|
+
duration?: number;
|
|
18
|
+
onEnd?: () => void;
|
|
19
|
+
onExit?: {
|
|
20
|
+
duration?: number;
|
|
21
|
+
before?: (datum: any) => AnimationStyle;
|
|
22
|
+
};
|
|
23
|
+
onEnter?: {
|
|
24
|
+
duration?: number;
|
|
25
|
+
before?: (datum: any) => AnimationStyle;
|
|
26
|
+
after?: (datum: any) => AnimationStyle;
|
|
27
|
+
};
|
|
28
|
+
onLoad?: {
|
|
29
|
+
duration?: number;
|
|
30
|
+
before?: (datum: any) => AnimationStyle;
|
|
31
|
+
after?: (datum: any) => AnimationStyle;
|
|
32
|
+
};
|
|
33
|
+
easing?: AnimationEasing;
|
|
34
|
+
animationWhitelist?: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface EventCallbackInterface<TTarget, TEventKey> {
|
|
38
|
+
childName?: string | string[];
|
|
39
|
+
target?: TTarget;
|
|
40
|
+
eventKey?: TEventKey;
|
|
41
|
+
mutation: (props: any) => any;
|
|
42
|
+
callback?: (props: any) => any;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface EventPropTypeInterface<TTarget, TEventKey> {
|
|
46
|
+
childName?: string | Array<StringOrNumberOrCallback>;
|
|
47
|
+
target: TTarget;
|
|
48
|
+
eventKey?: TEventKey;
|
|
49
|
+
eventHandlers: {
|
|
50
|
+
[key: string]:
|
|
51
|
+
| {
|
|
52
|
+
(
|
|
53
|
+
event: React.SyntheticEvent<any>,
|
|
54
|
+
props?: any
|
|
55
|
+
): EventCallbackInterface<TTarget, TEventKey>;
|
|
56
|
+
}
|
|
57
|
+
| {
|
|
58
|
+
(
|
|
59
|
+
event: React.SyntheticEvent<any>,
|
|
60
|
+
props?: any
|
|
61
|
+
): EventCallbackInterface<TTarget, TEventKey>[];
|
|
62
|
+
}
|
|
63
|
+
| {
|
|
64
|
+
(event: React.SyntheticEvent<any>, props?: any): void;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type DomainTuple = [number, number] | [Date, Date];
|
|
70
|
+
export type DomainPropObjectType =
|
|
71
|
+
| { x?: DomainTuple; y: DomainTuple }
|
|
72
|
+
| { x: DomainTuple; y?: DomainTuple };
|
|
73
|
+
export type DomainPropType = DomainPropObjectType | DomainTuple;
|
|
74
|
+
|
|
75
|
+
export type PaddingType = number | [number, number];
|
|
76
|
+
export type DomainPaddingPropType =
|
|
77
|
+
| PaddingType
|
|
78
|
+
| {
|
|
79
|
+
x?: PaddingType;
|
|
80
|
+
y?: PaddingType;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type RangeTuple = [number, number];
|
|
84
|
+
export type RangePropType = RangeTuple | { x?: RangeTuple; y?: RangeTuple };
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* D3 scale function shape. Don"t want to introduce typing dependency to d3
|
|
88
|
+
*/
|
|
89
|
+
export interface D3Scale {
|
|
90
|
+
(input: string | number): number;
|
|
91
|
+
domain: () => any;
|
|
92
|
+
range: () => any;
|
|
93
|
+
copy: () => any;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type ScalePropType = "linear" | "time" | "log" | "sqrt";
|
|
97
|
+
|
|
98
|
+
export type CategoryPropType =
|
|
99
|
+
| string[]
|
|
100
|
+
| { x: string[] }
|
|
101
|
+
| { y: string[] }
|
|
102
|
+
| {
|
|
103
|
+
x: string[];
|
|
104
|
+
y: string[];
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export type DataGetterPropType =
|
|
108
|
+
| number
|
|
109
|
+
| string
|
|
110
|
+
| string[]
|
|
111
|
+
| { (data: any): number | string | string[] }
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
113
|
+
| Function;
|
|
114
|
+
|
|
115
|
+
export type InterpolationPropType =
|
|
116
|
+
| "basis"
|
|
117
|
+
| "basisClosed"
|
|
118
|
+
| "basisOpen"
|
|
119
|
+
| "bundle"
|
|
120
|
+
| "cardinal"
|
|
121
|
+
| "cardinalClosed"
|
|
122
|
+
| "cardinalOpen"
|
|
123
|
+
| "catmullRom"
|
|
124
|
+
| "catmullRomClosed"
|
|
125
|
+
| "catmullRomOpen"
|
|
126
|
+
| "linear"
|
|
127
|
+
| "linearClosed"
|
|
128
|
+
| "monotoneX"
|
|
129
|
+
| "monotoneY"
|
|
130
|
+
| "natural"
|
|
131
|
+
| "radial"
|
|
132
|
+
| "step"
|
|
133
|
+
| "stepAfter"
|
|
134
|
+
| "stepBefore";
|
|
135
|
+
|
|
136
|
+
export type ColorScalePropType =
|
|
137
|
+
| "grayscale"
|
|
138
|
+
| "qualitative"
|
|
139
|
+
| "heatmap"
|
|
140
|
+
| "warm"
|
|
141
|
+
| "cool"
|
|
142
|
+
| "red"
|
|
143
|
+
| "green"
|
|
144
|
+
| "blue"
|
|
145
|
+
| string[];
|
|
146
|
+
|
|
147
|
+
export type SortOrderPropType = "ascending" | "descending";
|
|
148
|
+
|
|
149
|
+
export type SVGCoordinateType = { x: number; y: number };
|
|
150
|
+
|
|
151
|
+
export interface VictoryCommonThemeProps {
|
|
152
|
+
animate?: boolean | AnimatePropTypeInterface;
|
|
153
|
+
colorScale?: ColorScalePropType;
|
|
154
|
+
containerComponent?: React.ReactElement;
|
|
155
|
+
domainPadding?: DomainPaddingPropType;
|
|
156
|
+
externalEventMutations?: EventCallbackInterface<
|
|
157
|
+
string | string[],
|
|
158
|
+
StringOrNumberOrList
|
|
159
|
+
>[];
|
|
160
|
+
groupComponent?: React.ReactElement;
|
|
161
|
+
height?: number;
|
|
162
|
+
horizontal?: boolean;
|
|
163
|
+
maxDomain?: number | { x?: number; y?: number };
|
|
164
|
+
minDomain?: number | { x?: number; y?: number };
|
|
165
|
+
name?: string;
|
|
166
|
+
origin?: OriginType;
|
|
167
|
+
padding?: PaddingProps;
|
|
168
|
+
polar?: boolean;
|
|
169
|
+
range?: RangePropType;
|
|
170
|
+
scale?:
|
|
171
|
+
| ScalePropType
|
|
172
|
+
| D3Scale
|
|
173
|
+
| {
|
|
174
|
+
x?: ScalePropType | D3Scale;
|
|
175
|
+
y?: ScalePropType | D3Scale;
|
|
176
|
+
};
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
178
|
+
sharedEvents?: { events: any[]; getEventState: Function };
|
|
179
|
+
singleQuadrantDomainPadding?: boolean | { x?: boolean; y?: boolean };
|
|
180
|
+
standalone?: boolean;
|
|
181
|
+
width?: number;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface VictoryCommonProps extends VictoryCommonThemeProps {
|
|
185
|
+
theme?: VictoryThemeDefinition;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface VictoryCommonPrimitiveProps {
|
|
189
|
+
active?: boolean;
|
|
190
|
+
ariaLabel?: StringOrCallback;
|
|
191
|
+
className?: string;
|
|
192
|
+
clipPath?: string;
|
|
193
|
+
data?: any;
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
195
|
+
desc?: string | Function;
|
|
196
|
+
disableInlineStyles?: boolean;
|
|
197
|
+
events?: object;
|
|
198
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
199
|
+
id?: number | string | Function;
|
|
200
|
+
index?: number | string;
|
|
201
|
+
origin?: OriginType;
|
|
202
|
+
polar?: boolean;
|
|
203
|
+
role?: string;
|
|
204
|
+
scale?: any;
|
|
205
|
+
shapeRendering?: string;
|
|
206
|
+
style?: any;
|
|
207
|
+
tabIndex?: NumberOrCallback;
|
|
208
|
+
transform?: string;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface VictoryDatableProps {
|
|
212
|
+
categories?: CategoryPropType;
|
|
213
|
+
data?: any[];
|
|
214
|
+
dataComponent?: React.ReactElement;
|
|
215
|
+
domain?: DomainPropType;
|
|
216
|
+
domainPadding?: DomainPaddingPropType;
|
|
217
|
+
samples?: number;
|
|
218
|
+
sortKey?: DataGetterPropType;
|
|
219
|
+
sortOrder?: SortOrderPropType;
|
|
220
|
+
x?: DataGetterPropType;
|
|
221
|
+
y?: DataGetterPropType;
|
|
222
|
+
y0?: DataGetterPropType;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface VictoryLabelableProps {
|
|
226
|
+
labelComponent?: React.ReactElement;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface VictoryMultiLabelableProps extends VictoryLabelableProps {
|
|
230
|
+
labels?:
|
|
231
|
+
| string[]
|
|
232
|
+
| number[]
|
|
233
|
+
| { (data: any): string | string[] | number | number[] | null };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface VictorySingleLabelableProps extends VictoryLabelableProps {
|
|
237
|
+
label?: string | { (data: any): string | number | null };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface TextSizeStyleInterface {
|
|
241
|
+
angle?: number;
|
|
242
|
+
characterConstant?: string;
|
|
243
|
+
fontFamily?: string;
|
|
244
|
+
fontSize?: number | string;
|
|
245
|
+
letterSpacing?: string;
|
|
246
|
+
lineHeight?: number;
|
|
247
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
USER_PROPS_SAFELIST is to contain any string deemed safe for user props.
|
|
3
5
|
The startsWidth array will contain the start of any accepted user-prop that
|
|
@@ -48,6 +50,19 @@ const testIfSafeProp = (key) => {
|
|
|
48
50
|
return false;
|
|
49
51
|
};
|
|
50
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Gets the value from props if a function value is provided
|
|
55
|
+
* @param {any} value: maybe function value
|
|
56
|
+
* @param {Object} props: props object
|
|
57
|
+
* @returns {any} newValue
|
|
58
|
+
*/
|
|
59
|
+
const getValue = (value, props) => {
|
|
60
|
+
if (typeof value === "function") {
|
|
61
|
+
return value(props);
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
};
|
|
65
|
+
|
|
51
66
|
/**
|
|
52
67
|
* getSafeUserProps - function that takes in a props object and removes any
|
|
53
68
|
* key-value entries that do not match filter strings in the USER_PROPS_SAFELIST
|
|
@@ -59,6 +74,21 @@ const testIfSafeProp = (key) => {
|
|
|
59
74
|
export const getSafeUserProps = (props) => {
|
|
60
75
|
const propsToFilter = { ...props };
|
|
61
76
|
return Object.fromEntries(
|
|
62
|
-
Object.entries(propsToFilter)
|
|
77
|
+
Object.entries(propsToFilter)
|
|
78
|
+
.filter(([key]) => testIfSafeProp(key))
|
|
79
|
+
.map(([key, value]) => {
|
|
80
|
+
return [key, getValue(value, props)];
|
|
81
|
+
})
|
|
63
82
|
);
|
|
64
83
|
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Wraps a component and adds safe user props
|
|
87
|
+
*
|
|
88
|
+
* @param {ReactNode} component: parent component
|
|
89
|
+
* @param {Object} props: props to be filtered
|
|
90
|
+
* @returns {ReactNode} modified component
|
|
91
|
+
*/
|
|
92
|
+
export const withSafeUserProps = (component, props) => {
|
|
93
|
+
return React.cloneElement(component, getSafeUserProps(props));
|
|
94
|
+
};
|