victory-core 36.7.0 → 36.8.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 +28 -0
- package/dist/victory-core.js +371 -289
- package/dist/victory-core.min.js +1 -1
- package/es/victory-label/victory-label.js +12 -12
- package/es/victory-primitives/arc.d.ts +0 -5
- package/es/victory-primitives/arc.js +7 -7
- package/es/victory-primitives/background.d.ts +0 -6
- package/es/victory-primitives/background.js +8 -8
- package/es/victory-primitives/border.d.ts +0 -5
- package/es/victory-primitives/border.js +7 -7
- package/es/victory-primitives/circle.d.ts +2 -2
- package/es/victory-primitives/circle.js +30 -16
- package/es/victory-primitives/clip-path.d.ts +1 -8
- package/es/victory-primitives/clip-path.js +4 -10
- package/es/victory-primitives/line-segment.d.ts +0 -5
- package/es/victory-primitives/line-segment.js +7 -7
- package/es/victory-primitives/line.d.ts +2 -2
- package/es/victory-primitives/line.js +30 -16
- package/es/victory-primitives/path.d.ts +1 -1
- package/es/victory-primitives/path.js +24 -12
- package/es/victory-primitives/point.d.ts +0 -5
- package/es/victory-primitives/point.js +7 -7
- package/es/victory-primitives/rect.d.ts +2 -2
- package/es/victory-primitives/rect.js +30 -16
- package/es/victory-primitives/text.d.ts +1 -9
- package/es/victory-primitives/text.js +23 -13
- package/es/victory-primitives/tspan.js +30 -5
- package/es/victory-primitives/whisker.d.ts +0 -6
- package/es/victory-primitives/whisker.js +8 -8
- package/es/victory-util/add-events.d.ts +2 -2
- package/es/victory-util/add-events.js +4 -2
- package/es/victory-util/helpers.js +4 -3
- package/es/victory-util/textsize.js +7 -0
- package/es/victory-util/user-props.js +2 -16
- package/lib/victory-label/victory-label.js +13 -12
- package/lib/victory-primitives/arc.d.ts +0 -5
- package/lib/victory-primitives/arc.js +8 -7
- package/lib/victory-primitives/background.d.ts +0 -6
- package/lib/victory-primitives/background.js +9 -8
- package/lib/victory-primitives/border.d.ts +0 -5
- package/lib/victory-primitives/border.js +8 -7
- package/lib/victory-primitives/circle.d.ts +2 -2
- package/lib/victory-primitives/circle.js +34 -18
- package/lib/victory-primitives/clip-path.d.ts +1 -8
- package/lib/victory-primitives/clip-path.js +5 -12
- package/lib/victory-primitives/line-segment.d.ts +0 -5
- package/lib/victory-primitives/line-segment.js +8 -7
- package/lib/victory-primitives/line.d.ts +2 -2
- package/lib/victory-primitives/line.js +34 -18
- package/lib/victory-primitives/path.d.ts +1 -1
- package/lib/victory-primitives/path.js +25 -12
- package/lib/victory-primitives/point.d.ts +0 -5
- package/lib/victory-primitives/point.js +8 -7
- package/lib/victory-primitives/rect.d.ts +2 -2
- package/lib/victory-primitives/rect.js +34 -18
- package/lib/victory-primitives/text.d.ts +1 -9
- package/lib/victory-primitives/text.js +24 -14
- package/lib/victory-primitives/tspan.js +31 -5
- package/lib/victory-primitives/whisker.d.ts +0 -6
- package/lib/victory-primitives/whisker.js +9 -8
- package/lib/victory-util/add-events.d.ts +2 -2
- package/lib/victory-util/add-events.js +4 -2
- package/lib/victory-util/helpers.js +8 -3
- package/lib/victory-util/textsize.js +7 -0
- package/lib/victory-util/user-props.js +3 -16
- package/package.json +2 -2
- package/src/victory-label/victory-label.tsx +11 -12
- package/src/victory-primitives/arc.tsx +7 -7
- package/src/victory-primitives/background.tsx +8 -8
- package/src/victory-primitives/border.tsx +7 -7
- package/src/victory-primitives/circle.tsx +24 -14
- package/src/victory-primitives/clip-path.tsx +1 -13
- package/src/victory-primitives/line-segment.tsx +7 -7
- package/src/victory-primitives/line.tsx +25 -14
- package/src/victory-primitives/path.tsx +23 -17
- package/src/victory-primitives/point.tsx +7 -7
- package/src/victory-primitives/rect.tsx +25 -14
- package/src/victory-primitives/text.tsx +13 -10
- package/src/victory-primitives/tspan.tsx +15 -4
- package/src/victory-primitives/whisker.tsx +8 -8
- package/src/victory-util/add-events.tsx +14 -5
- package/src/victory-util/helpers.ts +5 -3
- package/src/victory-util/textsize.ts +5 -1
- package/src/victory-util/user-props.ts +2 -14
- package/es/v37/clone.d.ts +0 -23
- package/es/v37/clone.js +0 -32
- package/es/v37/index.d.ts +0 -5
- package/es/v37/index.js +0 -4
- package/es/v37/victory-state/defaults.d.ts +0 -3
- package/es/v37/victory-state/defaults.js +0 -2
- package/es/v37/victory-state/helpers/get-axis-data.d.ts +0 -3
- package/es/v37/victory-state/helpers/get-axis-data.js +0 -14
- package/es/v37/victory-state/helpers/get-data.d.ts +0 -15
- package/es/v37/victory-state/helpers/get-data.js +0 -87
- package/es/v37/victory-state/helpers/get-domain.d.ts +0 -6
- package/es/v37/victory-state/helpers/get-domain.js +0 -67
- package/es/v37/victory-state/helpers/get-range.d.ts +0 -6
- package/es/v37/victory-state/helpers/get-range.js +0 -36
- package/es/v37/victory-state/helpers/get-scale.d.ts +0 -6
- package/es/v37/victory-state/helpers/get-scale.js +0 -58
- package/es/v37/victory-state/index.d.ts +0 -4
- package/es/v37/victory-state/index.js +0 -3
- package/es/v37/victory-state/types.d.ts +0 -24
- package/es/v37/victory-state/types.js +0 -1
- package/es/v37/victory-state/victory-provider.d.ts +0 -21
- package/es/v37/victory-state/victory-provider.js +0 -148
- package/es/v37/victory-state/with-victory-provider.d.ts +0 -7
- package/es/v37/victory-state/with-victory-provider.js +0 -43
- package/es/v37/with-container.d.ts +0 -5
- package/es/v37/with-container.js +0 -32
- package/es/v37/with-normalized-props.d.ts +0 -17
- package/es/v37/with-normalized-props.js +0 -18
- package/lib/v37/clone.d.ts +0 -23
- package/lib/v37/clone.js +0 -43
- package/lib/v37/index.d.ts +0 -5
- package/lib/v37/index.js +0 -57
- package/lib/v37/victory-state/defaults.d.ts +0 -3
- package/lib/v37/victory-state/defaults.js +0 -10
- package/lib/v37/victory-state/helpers/get-axis-data.d.ts +0 -3
- package/lib/v37/victory-state/helpers/get-axis-data.js +0 -22
- package/lib/v37/victory-state/helpers/get-data.d.ts +0 -15
- package/lib/v37/victory-state/helpers/get-data.js +0 -98
- package/lib/v37/victory-state/helpers/get-domain.d.ts +0 -6
- package/lib/v37/victory-state/helpers/get-domain.js +0 -81
- package/lib/v37/victory-state/helpers/get-range.d.ts +0 -6
- package/lib/v37/victory-state/helpers/get-range.js +0 -45
- package/lib/v37/victory-state/helpers/get-scale.d.ts +0 -6
- package/lib/v37/victory-state/helpers/get-scale.js +0 -73
- package/lib/v37/victory-state/index.d.ts +0 -4
- package/lib/v37/victory-state/index.js +0 -44
- package/lib/v37/victory-state/types.d.ts +0 -24
- package/lib/v37/victory-state/types.js +0 -1
- package/lib/v37/victory-state/victory-provider.d.ts +0 -21
- package/lib/v37/victory-state/victory-provider.js +0 -175
- package/lib/v37/victory-state/with-victory-provider.d.ts +0 -7
- package/lib/v37/victory-state/with-victory-provider.js +0 -56
- package/lib/v37/with-container.d.ts +0 -5
- package/lib/v37/with-container.js +0 -45
- package/lib/v37/with-normalized-props.d.ts +0 -17
- package/lib/v37/with-normalized-props.js +0 -29
- package/src/v37/clone.tsx +0 -30
- package/src/v37/index.tsx +0 -4
- package/src/v37/victory-state/defaults.ts +0 -2
- package/src/v37/victory-state/helpers/get-axis-data.ts +0 -14
- package/src/v37/victory-state/helpers/get-data.ts +0 -78
- package/src/v37/victory-state/helpers/get-domain.ts +0 -62
- package/src/v37/victory-state/helpers/get-range.ts +0 -39
- package/src/v37/victory-state/helpers/get-scale.ts +0 -67
- package/src/v37/victory-state/index.ts +0 -3
- package/src/v37/victory-state/types.ts +0 -32
- package/src/v37/victory-state/victory-provider.tsx +0 -152
- package/src/v37/victory-state/with-victory-provider.tsx +0 -53
- package/src/v37/with-container.tsx +0 -38
- package/src/v37/with-normalized-props.tsx +0 -43
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
D3ScaleFn,
|
|
3
|
-
Datum,
|
|
4
|
-
DomainTuple,
|
|
5
|
-
RangeTuple,
|
|
6
|
-
ScalePropType,
|
|
7
|
-
ValueOrAxes,
|
|
8
|
-
} from "../../types/prop-types";
|
|
9
|
-
import { PaddingProps } from "../../victory-theme/types";
|
|
10
|
-
|
|
11
|
-
// These are all the props that are used to calculate data, domain, range, and scale
|
|
12
|
-
export interface VictoryCalculatedStateProps {
|
|
13
|
-
data?: Datum[];
|
|
14
|
-
domain?: ValueOrAxes<DomainTuple>;
|
|
15
|
-
height?: number;
|
|
16
|
-
includeZero?: boolean;
|
|
17
|
-
maxDomain?: ValueOrAxes<number>;
|
|
18
|
-
minDomain?: ValueOrAxes<number>;
|
|
19
|
-
padding?: PaddingProps;
|
|
20
|
-
range?: ValueOrAxes<RangeTuple>;
|
|
21
|
-
samples?: number;
|
|
22
|
-
scale?: ValueOrAxes<ScalePropType | D3ScaleFn>;
|
|
23
|
-
sortKey?: string;
|
|
24
|
-
sortOrder?: "ascending" | "descending";
|
|
25
|
-
width?: number;
|
|
26
|
-
x?: string;
|
|
27
|
-
y?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface VictoryProviderProps extends VictoryCalculatedStateProps {
|
|
31
|
-
children?: React.ReactNode;
|
|
32
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
import { D3ScaleFn, DomainTuple, ForAxes } from "../../types/prop-types";
|
|
4
|
-
import { FormattedDatum, getData } from "./helpers/get-data";
|
|
5
|
-
import { getDomain } from "./helpers/get-domain";
|
|
6
|
-
import { getRange } from "./helpers/get-range";
|
|
7
|
-
import { getScale } from "./helpers/get-scale";
|
|
8
|
-
import { VictoryCalculatedStateProps, VictoryProviderProps } from "./types";
|
|
9
|
-
|
|
10
|
-
type ScaleType = Required<ForAxes<D3ScaleFn>>;
|
|
11
|
-
type DomainType = Required<ForAxes<DomainTuple>>;
|
|
12
|
-
|
|
13
|
-
export interface ContextType {
|
|
14
|
-
data: FormattedDatum[];
|
|
15
|
-
scale: ScaleType;
|
|
16
|
-
domain: DomainType;
|
|
17
|
-
updateChildProps: (id: symbol, props: VictoryProviderProps | null) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const VictoryContext = createContext<ContextType | null>(null);
|
|
21
|
-
|
|
22
|
-
type CollectedProps = { [id: symbol]: VictoryCalculatedStateProps };
|
|
23
|
-
|
|
24
|
-
function useNormalizedProps(): ContextType {
|
|
25
|
-
const [collectedProps, setCollectedProps] = React.useState<CollectedProps>(
|
|
26
|
-
{},
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
const updateChildProps = React.useCallback(
|
|
30
|
-
(id: symbol, newProps: VictoryCalculatedStateProps | null) => {
|
|
31
|
-
setCollectedProps((prev) => {
|
|
32
|
-
const result = { ...prev };
|
|
33
|
-
if (newProps === null) {
|
|
34
|
-
delete result[id];
|
|
35
|
-
} else {
|
|
36
|
-
result[id] = newProps;
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
[],
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
// TEMP: combine all props into a single result:
|
|
45
|
-
// TODO: instead, we should intelligently aggregate all these props
|
|
46
|
-
const props = Object.values(
|
|
47
|
-
collectedProps,
|
|
48
|
-
).reduce<VictoryCalculatedStateProps>(
|
|
49
|
-
(result, childProps) => Object.assign(result, childProps),
|
|
50
|
-
{},
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
const data = React.useMemo(() => {
|
|
54
|
-
return getData(props);
|
|
55
|
-
}, [props]);
|
|
56
|
-
|
|
57
|
-
const domain = React.useMemo(() => {
|
|
58
|
-
return {
|
|
59
|
-
x: getDomain(props, "x"),
|
|
60
|
-
y: getDomain(props, "y"),
|
|
61
|
-
};
|
|
62
|
-
}, [props]);
|
|
63
|
-
|
|
64
|
-
const range = React.useMemo(
|
|
65
|
-
() => ({
|
|
66
|
-
x: getRange(props, "x"),
|
|
67
|
-
y: getRange(props, "y"),
|
|
68
|
-
}),
|
|
69
|
-
[props],
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
const scale = React.useMemo(() => {
|
|
73
|
-
const xBaseScaleFn = getScale(props, "x");
|
|
74
|
-
const yBaseScaleFn = getScale(props, "y");
|
|
75
|
-
|
|
76
|
-
// @ts-expect-error: This is a valid scale function
|
|
77
|
-
const xScaleFn = xBaseScaleFn().domain(domain.x).range(range.x);
|
|
78
|
-
// @ts-expect-error: This is a valid scale function
|
|
79
|
-
const yScaleFn = yBaseScaleFn().domain(domain.y).range(range.y);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
x: xScaleFn,
|
|
83
|
-
y: yScaleFn,
|
|
84
|
-
};
|
|
85
|
-
}, [props, domain, range]);
|
|
86
|
-
|
|
87
|
-
const normalizedProps = React.useMemo(
|
|
88
|
-
() => ({
|
|
89
|
-
scale,
|
|
90
|
-
data,
|
|
91
|
-
domain,
|
|
92
|
-
updateChildProps,
|
|
93
|
-
}),
|
|
94
|
-
[scale, data, domain, updateChildProps],
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
return normalizedProps;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function VictoryProvider({
|
|
101
|
-
children,
|
|
102
|
-
// Disabled due to TODO below which will require this obj. spread
|
|
103
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
104
|
-
...providerProps
|
|
105
|
-
}: VictoryProviderProps) {
|
|
106
|
-
const value = useNormalizedProps();
|
|
107
|
-
|
|
108
|
-
// TODO: sync the providerProps
|
|
109
|
-
|
|
110
|
-
return (
|
|
111
|
-
<VictoryContext.Provider value={value}>{children}</VictoryContext.Provider>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function useVictoryContextMaybe<T>(
|
|
116
|
-
selector: (value: ContextType | null) => T,
|
|
117
|
-
): T {
|
|
118
|
-
const context = useContext(VictoryContext);
|
|
119
|
-
return selector(context);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function useVictoryContext<T>(selector: (value: ContextType) => T): T {
|
|
123
|
-
const context = useContext(VictoryContext);
|
|
124
|
-
if (!context) {
|
|
125
|
-
throw new Error("useVictoryContext must be used within a VictoryProvider");
|
|
126
|
-
}
|
|
127
|
-
return selector(context);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export function useScale() {
|
|
131
|
-
return useVictoryContext<ScaleType>((value) => value.scale);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export function useData() {
|
|
135
|
-
return useVictoryContext<FormattedDatum[]>((value) => value.data);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export function useDomain() {
|
|
139
|
-
return useVictoryContext<DomainType>((value) => value.domain);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// This function keeps props in sync betwen the VictoryProvider and child components
|
|
143
|
-
export function useVictoryProviderSync(props: VictoryCalculatedStateProps) {
|
|
144
|
-
const updateChildProps = useVictoryContext((value) => value.updateChildProps);
|
|
145
|
-
const [myId] = React.useState(() =>
|
|
146
|
-
Symbol("UniqueIdFor(VictoryProviderChild)"),
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
React.useEffect(() => {
|
|
150
|
-
updateChildProps(myId, props);
|
|
151
|
-
}, [updateChildProps, props, myId]);
|
|
152
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useVictoryContextMaybe, VictoryProvider } from "./victory-provider";
|
|
3
|
-
import { VictoryCommonProps } from "../../victory-util/common-props";
|
|
4
|
-
import { Clone } from "../clone";
|
|
5
|
-
import { VictoryProviderProps } from "./types";
|
|
6
|
-
|
|
7
|
-
/* eslint-disable react/prop-types */
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Ensures the component is wrapped by a VictoryProvider, if not already.
|
|
11
|
-
*/
|
|
12
|
-
export function withVictoryProvider<
|
|
13
|
-
TComp extends React.FC<TProps>,
|
|
14
|
-
TProps extends React.PropsWithChildren<VictoryCommonProps>,
|
|
15
|
-
>(Comp: TComp): TComp {
|
|
16
|
-
const WithVictoryProvider = React.memo((props: TProps) => {
|
|
17
|
-
const updateChildProps = useVictoryContextMaybe(
|
|
18
|
-
(value) => value?.updateChildProps,
|
|
19
|
-
);
|
|
20
|
-
const hasParentProvider = !!updateChildProps;
|
|
21
|
-
|
|
22
|
-
React.useEffect(() => {
|
|
23
|
-
if (!hasParentProvider) return;
|
|
24
|
-
|
|
25
|
-
const id = Symbol("WithVictoryProvider");
|
|
26
|
-
updateChildProps(id, props as VictoryProviderProps);
|
|
27
|
-
// eslint-disable-next-line consistent-return
|
|
28
|
-
return () => updateChildProps(id, null);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// @ts-expect-error "TProps not assignable to LibraryManagedAttributes"
|
|
32
|
-
let result = <Comp {...props}>{props.children}</Comp>;
|
|
33
|
-
|
|
34
|
-
if (!hasParentProvider) {
|
|
35
|
-
// Wrap with a parent Provider:
|
|
36
|
-
result = (
|
|
37
|
-
<VictoryProvider>
|
|
38
|
-
<Clone element={props.containerComponent} {...props}>
|
|
39
|
-
{result}
|
|
40
|
-
</Clone>
|
|
41
|
-
</VictoryProvider>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return result;
|
|
45
|
-
});
|
|
46
|
-
const name = Comp.displayName || Comp.name;
|
|
47
|
-
WithVictoryProvider.displayName = name
|
|
48
|
-
? `WithVictoryProvider(${name})`
|
|
49
|
-
: "WithVictoryProvider";
|
|
50
|
-
|
|
51
|
-
// @ts-expect-error "WithVictoryProvider does not overlap with TComp"
|
|
52
|
-
return WithVictoryProvider as TComp;
|
|
53
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { VictoryProvider, VictoryProviderProps } from "./victory-state";
|
|
3
|
-
import { VictoryContainer } from "../victory-container/victory-container";
|
|
4
|
-
import { VictoryCommonProps } from "../victory-util/common-props";
|
|
5
|
-
|
|
6
|
-
const defaultProviderProps = {
|
|
7
|
-
width: 450,
|
|
8
|
-
height: 300,
|
|
9
|
-
padding: 50,
|
|
10
|
-
data: [],
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function withContainer<Props extends VictoryCommonProps>(
|
|
14
|
-
WrappedComponent: React.FC<Props>,
|
|
15
|
-
initialProviderProps: Partial<VictoryProviderProps> = {},
|
|
16
|
-
): React.FC<Props> {
|
|
17
|
-
return (props: Props) => {
|
|
18
|
-
const providerProps = {
|
|
19
|
-
...defaultProviderProps,
|
|
20
|
-
...initialProviderProps,
|
|
21
|
-
...props,
|
|
22
|
-
};
|
|
23
|
-
const { standalone = true, containerComponent = <VictoryContainer /> } =
|
|
24
|
-
props;
|
|
25
|
-
if (standalone) {
|
|
26
|
-
return (
|
|
27
|
-
<VictoryProvider {...providerProps}>
|
|
28
|
-
{React.cloneElement(
|
|
29
|
-
containerComponent,
|
|
30
|
-
providerProps,
|
|
31
|
-
<WrappedComponent {...props} />,
|
|
32
|
-
)}
|
|
33
|
-
</VictoryProvider>
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
return <WrappedComponent {...props} />;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { VictoryCommonProps } from "../victory-util/common-props";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
useVictoryContext,
|
|
5
|
-
VictoryProviderProps,
|
|
6
|
-
withVictoryProvider,
|
|
7
|
-
} from "./victory-state";
|
|
8
|
-
|
|
9
|
-
type FC<TProps> = (props: TProps) => JSX.Element;
|
|
10
|
-
|
|
11
|
-
export function withNormalizedProps<
|
|
12
|
-
TProps extends React.PropsWithChildren<VictoryCommonProps>,
|
|
13
|
-
TDefaultPropKeys extends keyof TProps,
|
|
14
|
-
>(
|
|
15
|
-
config: {
|
|
16
|
-
displayName: string;
|
|
17
|
-
propTypes?: React.WeakValidationMap<Omit<TProps, keyof VictoryCommonProps>>;
|
|
18
|
-
defaultProps: Pick<TProps, TDefaultPropKeys>;
|
|
19
|
-
/** @deprecated */
|
|
20
|
-
initialProviderProps?: Partial<VictoryProviderProps>;
|
|
21
|
-
},
|
|
22
|
-
WrappedComponent: React.FC<TProps>,
|
|
23
|
-
) {
|
|
24
|
-
WrappedComponent.displayName = config.displayName;
|
|
25
|
-
const WithNormalizedProps: FC<TProps> = withVictoryProvider<
|
|
26
|
-
FC<TProps>,
|
|
27
|
-
TProps
|
|
28
|
-
>((props: TProps) => {
|
|
29
|
-
const normalizedProps = useVictoryContext((v) => v);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<WrappedComponent {...props} {...normalizedProps}>
|
|
33
|
-
{props.children}
|
|
34
|
-
</WrappedComponent>
|
|
35
|
-
);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return Object.assign(WithNormalizedProps, {
|
|
39
|
-
displayName: `WithNormalizedProps(${config.displayName}`,
|
|
40
|
-
defaultProps: config.defaultProps,
|
|
41
|
-
propTypes: config.propTypes,
|
|
42
|
-
});
|
|
43
|
-
}
|