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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _identity from "lodash/identity";
|
|
2
|
-
import _defaults from "lodash/defaults";
|
|
3
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import identity from "lodash/identity";
|
|
4
4
|
function getDatumKey(datum, idx) {
|
|
5
5
|
return (datum.key || idx).toString();
|
|
6
6
|
}
|
|
@@ -108,7 +108,7 @@ export function getInitialTransitionState(oldChildren, nextChildren) {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
function getInitialChildProps(animate, data) {
|
|
111
|
-
const after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after :
|
|
111
|
+
const after = animate.onEnter && animate.onEnter.after ? animate.onEnter.after : identity;
|
|
112
112
|
return {
|
|
113
113
|
data: data.map((datum, idx) => Object.assign({}, datum, after(datum, idx, data)))
|
|
114
114
|
};
|
|
@@ -125,7 +125,7 @@ function getChildBeforeLoad(animate, child, data, cb) {
|
|
|
125
125
|
data
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
|
-
const before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before :
|
|
128
|
+
const before = newAnimate.onLoad && newAnimate.onLoad.before ? newAnimate.onLoad.before : identity;
|
|
129
129
|
// If nodes need to exit, transform them with the provided onLoad.before function.
|
|
130
130
|
const newData = data.map((datum, idx) => {
|
|
131
131
|
return Object.assign({}, datum, before(datum, idx, data));
|
|
@@ -136,8 +136,6 @@ function getChildBeforeLoad(animate, child, data, cb) {
|
|
|
136
136
|
clipWidth: 0
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
|
|
140
|
-
// eslint-disable-next-line max-params
|
|
141
139
|
function getChildOnLoad(animate, data, cb) {
|
|
142
140
|
const newAnimate = Object.assign({}, animate, {
|
|
143
141
|
onEnd: cb
|
|
@@ -149,7 +147,7 @@ function getChildOnLoad(animate, data, cb) {
|
|
|
149
147
|
data
|
|
150
148
|
};
|
|
151
149
|
}
|
|
152
|
-
const after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after :
|
|
150
|
+
const after = animate.onLoad && animate.onLoad.after ? animate.onLoad.after : identity;
|
|
153
151
|
// If nodes need to exit, transform them with the provided onLoad.after function.
|
|
154
152
|
newData = data.map((datum, idx) => {
|
|
155
153
|
return Object.assign({}, datum, after(datum, idx, data));
|
|
@@ -160,7 +158,7 @@ function getChildOnLoad(animate, data, cb) {
|
|
|
160
158
|
};
|
|
161
159
|
}
|
|
162
160
|
|
|
163
|
-
// eslint-disable-next-line max-params
|
|
161
|
+
// eslint-disable-next-line max-params
|
|
164
162
|
function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
165
163
|
// Whether or not _this_ child has exiting nodes, we want the exit-
|
|
166
164
|
// transition for all children to have the same duration, delay, etc.
|
|
@@ -171,7 +169,7 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
171
169
|
// After the exit transition occurs, trigger the animations for
|
|
172
170
|
// nodes that are neither exiting nor entering.
|
|
173
171
|
animate.onEnd = cb;
|
|
174
|
-
const before = animate.onExit && animate.onExit.before ? animate.onExit.before :
|
|
172
|
+
const before = animate.onExit && animate.onExit.before ? animate.onExit.before : identity;
|
|
175
173
|
// If nodes need to exit, transform them with the provided onExit.before function.
|
|
176
174
|
newData = data.map((datum, idx) => {
|
|
177
175
|
const key = (datum.key || idx).toString();
|
|
@@ -184,7 +182,7 @@ function getChildPropsOnExit(animate, child, data, exitingNodes, cb) {
|
|
|
184
182
|
};
|
|
185
183
|
}
|
|
186
184
|
|
|
187
|
-
// eslint-disable-next-line max-params
|
|
185
|
+
// eslint-disable-next-line max-params
|
|
188
186
|
function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
189
187
|
let newAnimate = animate;
|
|
190
188
|
let newData = data;
|
|
@@ -194,7 +192,7 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
|
194
192
|
newAnimate = Object.assign({}, animate, {
|
|
195
193
|
onEnd: cb
|
|
196
194
|
});
|
|
197
|
-
const before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before :
|
|
195
|
+
const before = animate.onEnter && animate.onEnter.before ? animate.onEnter.before : identity;
|
|
198
196
|
// We want the entering nodes to be included in the transition target
|
|
199
197
|
// domain. However, we may not want these nodes to be displayed initially,
|
|
200
198
|
// so perform the `onEnter.before` transformation on each node.
|
|
@@ -209,7 +207,7 @@ function getChildPropsBeforeEnter(animate, child, data, enteringNodes, cb) {
|
|
|
209
207
|
};
|
|
210
208
|
}
|
|
211
209
|
|
|
212
|
-
// eslint-disable-next-line max-params
|
|
210
|
+
// eslint-disable-next-line max-params
|
|
213
211
|
function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
214
212
|
// Whether or not _this_ child has entering nodes, we want the entering-
|
|
215
213
|
// transition for all children to have the same duration, delay, etc.
|
|
@@ -221,7 +219,7 @@ function getChildPropsOnEnter(animate, data, enteringNodes, cb) {
|
|
|
221
219
|
// domain should encompass the nodes that will now enter. So perform
|
|
222
220
|
// the `onEnter.after` transformation on each node.
|
|
223
221
|
newAnimate.onEnd = cb;
|
|
224
|
-
const after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after :
|
|
222
|
+
const after = newAnimate.onEnter && newAnimate.onEnter.after ? newAnimate.onEnter.after : identity;
|
|
225
223
|
newData = data.map((datum, idx) => {
|
|
226
224
|
const key = getDatumKey(datum, idx);
|
|
227
225
|
return enteringNodes[key] ? Object.assign({}, datum, after(datum, idx, data)) : datum;
|
|
@@ -316,15 +314,13 @@ export function getTransitionPropsFactory(props, state, setState) {
|
|
|
316
314
|
}
|
|
317
315
|
return {};
|
|
318
316
|
};
|
|
319
|
-
|
|
320
|
-
// eslint-disable-next-line max-statements, complexity, max-len
|
|
321
317
|
return function getTransitionProps(child, index) {
|
|
322
318
|
const data = getChildData(child) || [];
|
|
323
|
-
const animate =
|
|
319
|
+
const animate = defaults({}, props.animate, child.props.animate);
|
|
324
320
|
const defaultTransitions = child.props.polar ? child.type.defaultPolarTransitions || child.type.defaultTransitions : child.type.defaultTransitions;
|
|
325
|
-
animate.onExit =
|
|
326
|
-
animate.onEnter =
|
|
327
|
-
animate.onLoad =
|
|
321
|
+
animate.onExit = defaults({}, animate.onExit, defaultTransitions && defaultTransitions.onExit);
|
|
322
|
+
animate.onEnter = defaults({}, animate.onEnter, defaultTransitions && defaultTransitions.onEnter);
|
|
323
|
+
animate.onLoad = defaults({}, animate.onLoad, defaultTransitions && defaultTransitions.onLoad);
|
|
328
324
|
const childTransitions = childrenTransitions[index] || childrenTransitions[0];
|
|
329
325
|
if (!nodesDoneLoad) {
|
|
330
326
|
// should do onLoad animation
|
|
@@ -2,7 +2,6 @@ import { ForAxes, AxisType, Tuple, Datum, DatumValue } from "../types/prop-types
|
|
|
2
2
|
export declare function hasValueForAxis<T = unknown>(value: unknown | ForAxes<T>, axis: AxisType): value is ForAxes<T>;
|
|
3
3
|
export declare function isTuple<T = unknown>(value: unknown): value is Tuple<T>;
|
|
4
4
|
export declare function getValueForAxis<T = unknown>(value: T | ForAxes<T> | undefined, axis: AxisType): T | undefined;
|
|
5
|
-
export declare function isFunction<T = Function>(func?: unknown): func is T;
|
|
6
5
|
export declare function isDate(value: unknown): value is Date;
|
|
7
6
|
export declare function isKeyValueObject(datum: Datum): datum is {
|
|
8
7
|
[key: string]: DatumValue;
|
|
@@ -13,11 +13,6 @@ export function getValueForAxis(value, axis) {
|
|
|
13
13
|
}
|
|
14
14
|
return value;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
18
|
-
export function isFunction(func) {
|
|
19
|
-
return typeof func === "function";
|
|
20
|
-
}
|
|
21
16
|
export function isDate(value) {
|
|
22
17
|
return value instanceof Date;
|
|
23
18
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
2
|
+
type SafeAttribute = string;
|
|
3
3
|
/**
|
|
4
4
|
* Asserts that value is not null or undefined, throwing an error if it is.
|
|
5
5
|
* @param value The value to assert
|
|
@@ -14,7 +14,7 @@ export declare function assert<T>(value: T, message?: string): asserts value is
|
|
|
14
14
|
* @param {Object} props: props to be filtered against USER_PROPS_SAFELIST
|
|
15
15
|
* @returns {Object}: object containing remaining acceptable props
|
|
16
16
|
*/
|
|
17
|
-
export declare const getSafeUserProps: <T>(props: T) => Record<SafeAttribute, string>;
|
|
17
|
+
export declare const getSafeUserProps: <T>(props: T extends Record<string, any> ? T : never) => Record<SafeAttribute, string>;
|
|
18
18
|
/**
|
|
19
19
|
* Wraps a component and adds safe user props
|
|
20
20
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import _uniqBy from "lodash/uniqBy";
|
|
2
|
-
import _groupBy from "lodash/groupBy";
|
|
3
|
-
import _uniq from "lodash/uniq";
|
|
4
|
-
import _defaults from "lodash/defaults";
|
|
5
1
|
import React from "react";
|
|
2
|
+
import defaults from "lodash/defaults";
|
|
3
|
+
import uniq from "lodash/uniq";
|
|
4
|
+
import groupBy from "lodash/groupBy";
|
|
5
|
+
import uniqBy from "lodash/uniqBy";
|
|
6
6
|
import * as Axis from "./axis";
|
|
7
7
|
import * as Style from "./style";
|
|
8
8
|
import * as Data from "./data";
|
|
@@ -108,10 +108,10 @@ export function getDataFromChildren(props, childComponents) {
|
|
|
108
108
|
}, datum));
|
|
109
109
|
};
|
|
110
110
|
const stacked = children.filter(c => c.type && c.type.role === "stack").length;
|
|
111
|
-
const combine = (memo, val) => memo.concat(
|
|
111
|
+
const combine = (memo, val) => memo.concat(uniqBy(val, "_group"));
|
|
112
112
|
const datasets = Helpers.reduceChildren(children, iteratee, props, [], combine);
|
|
113
113
|
const group = stacked ? "_group" : "_stack";
|
|
114
|
-
return Object.values(
|
|
114
|
+
return Object.values(groupBy(datasets, group));
|
|
115
115
|
}
|
|
116
116
|
export function getData(props, childComponents) {
|
|
117
117
|
if (props.data) {
|
|
@@ -169,7 +169,6 @@ export function getDefaultDomainPadding(props, axis, childComponents) {
|
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
export function getDomainFromChildren(props, axis, childComponents) {
|
|
172
|
-
// eslint-disable-line max-statements, complexity, max-len
|
|
173
172
|
const children = childComponents ? childComponents.slice(0) : React.Children.toArray(props.children);
|
|
174
173
|
const parentData = props.data ? Data.getData(props) : undefined;
|
|
175
174
|
const {
|
|
@@ -239,7 +238,7 @@ export function getScale(props, axis, childComponents) {
|
|
|
239
238
|
});
|
|
240
239
|
return Scale.getScaleType(sharedProps, axis);
|
|
241
240
|
};
|
|
242
|
-
const childScale =
|
|
241
|
+
const childScale = uniq(Helpers.reduceChildren(children, iteratee, props));
|
|
243
242
|
|
|
244
243
|
// default to linear scale if more than one uniq scale type is given by children
|
|
245
244
|
return childScale.length > 1 ? Scale.getScaleFromName("linear") : Scale.getScaleFromName(childScale[0]);
|
|
@@ -301,8 +300,8 @@ export function getChildStyle(child, index, calculatedProps, theme) {
|
|
|
301
300
|
const dataWidth = role === "stack" ? {} : {
|
|
302
301
|
width: getWidth(calculatedProps)
|
|
303
302
|
};
|
|
304
|
-
const dataStyle =
|
|
305
|
-
const labelsStyle =
|
|
303
|
+
const dataStyle = defaults({}, childStyle.data, Object.assign({}, dataWidth, style.data, defaultColor));
|
|
304
|
+
const labelsStyle = defaults({}, childStyle.labels, style.labels);
|
|
306
305
|
return {
|
|
307
306
|
...childStyle,
|
|
308
307
|
parent: style.parent,
|
|
@@ -355,7 +354,7 @@ export function getCategoryAndAxisStringsFromChildren(props, axis, childComponen
|
|
|
355
354
|
const axisComponent = Axis.getAxisComponent(childComponents, axis);
|
|
356
355
|
const axisStrings = axisComponent ? Data.getStringsFromAxes(axisComponent.props, axis) : [];
|
|
357
356
|
const categoryStrings = categories.length ? categories : getStringsFromChildrenCategories(childComponents, axis);
|
|
358
|
-
return
|
|
357
|
+
return uniq([...categoryStrings, ...axisStrings].flat());
|
|
359
358
|
}
|
|
360
359
|
export function getStringsFromChildren(props, childComponents) {
|
|
361
360
|
const children = childComponents || React.Children.toArray(props.children);
|
|
@@ -363,8 +362,8 @@ export function getStringsFromChildren(props, childComponents) {
|
|
|
363
362
|
const yStrings = getCategoryAndAxisStringsFromChildren(props, "y", children);
|
|
364
363
|
const dataStrings = getStringsFromData(children);
|
|
365
364
|
return {
|
|
366
|
-
x:
|
|
367
|
-
y:
|
|
365
|
+
x: uniq([...xStrings, ...dataStrings.x].flat()),
|
|
366
|
+
y: uniq([...yStrings, ...dataStrings.y].flat())
|
|
368
367
|
};
|
|
369
368
|
}
|
|
370
369
|
export function getCategories(props, childComponents, allStrings) {
|
package/lib/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
|
|
@@ -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
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.victoryInterpolator = exports.isInterpolatable = exports.interpolateString = exports.interpolateObject = exports.interpolateImmediate = exports.interpolateFunction = void 0;
|
|
7
|
-
var
|
|
8
|
-
var
|
|
7
|
+
var _isPlainObject = _interopRequireDefault(require("lodash/isPlainObject"));
|
|
8
|
+
var _orderBy = _interopRequireDefault(require("lodash/orderBy"));
|
|
9
9
|
var _d3Interpolate = require("victory-vendor/d3-interpolate");
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
const isInterpolatable = function (obj) {
|
|
@@ -29,7 +29,7 @@ const isInterpolatable = function (obj) {
|
|
|
29
29
|
return false;
|
|
30
30
|
case "object":
|
|
31
31
|
// Don't try to interpolate class instances (except Date or Array).
|
|
32
|
-
return obj instanceof Date || Array.isArray(obj) || (0,
|
|
32
|
+
return obj instanceof Date || Array.isArray(obj) || (0, _isPlainObject.default)(obj);
|
|
33
33
|
case "function":
|
|
34
34
|
// Careful! There may be extra properties on function objects that the
|
|
35
35
|
// component expects to access - for instance, it may be a `d3.scale()`
|
|
@@ -91,7 +91,7 @@ const interpolateFunction = function (a, b) {
|
|
|
91
91
|
return b;
|
|
92
92
|
}
|
|
93
93
|
return function () {
|
|
94
|
-
/* eslint-disable
|
|
94
|
+
/* eslint-disable prefer-rest-params */
|
|
95
95
|
const aval = typeof a === "function" ? a.apply(this, arguments) : a;
|
|
96
96
|
const bval = typeof b === "function" ? b.apply(this, arguments) : b;
|
|
97
97
|
return (0, _d3Interpolate.interpolate)(aval, bval)(t);
|
|
@@ -118,7 +118,7 @@ const interpolateObject = function (startValue, endValue) {
|
|
|
118
118
|
if (typeof x === "function" || typeof y === "function") {
|
|
119
119
|
return interpolateFunction(x, y);
|
|
120
120
|
}
|
|
121
|
-
if (typeof x === "object" && (0,
|
|
121
|
+
if (typeof x === "object" && (0, _isPlainObject.default)(x) || typeof y === "object" && (0, _isPlainObject.default)(y)) {
|
|
122
122
|
return interpolateObject(x, y);
|
|
123
123
|
}
|
|
124
124
|
return (0, _d3Interpolate.interpolate)(x, y);
|
|
@@ -127,7 +127,7 @@ const interpolateObject = function (startValue, endValue) {
|
|
|
127
127
|
// When the value is an array, attempt to sort by "key" so that animating nodes may be identified
|
|
128
128
|
// based on "key" instead of index
|
|
129
129
|
const keyData = val => {
|
|
130
|
-
return Array.isArray(val) ? (0,
|
|
130
|
+
return Array.isArray(val) ? (0, _orderBy.default)(val, "key") : val;
|
|
131
131
|
};
|
|
132
132
|
const i = {};
|
|
133
133
|
const c = {};
|
|
@@ -196,7 +196,7 @@ const victoryInterpolator = function (a, b) {
|
|
|
196
196
|
if (typeof a === "function" || typeof b === "function") {
|
|
197
197
|
return interpolateFunction(a, b);
|
|
198
198
|
}
|
|
199
|
-
if ((0,
|
|
199
|
+
if ((0, _isPlainObject.default)(a) || (0, _isPlainObject.default)(b)) {
|
|
200
200
|
// @ts-expect-error These generics are tough, but they work :)
|
|
201
201
|
return interpolateObject(a, b);
|
|
202
202
|
}
|
|
@@ -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
|
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.VictoryClipContainer = void 0;
|
|
7
|
-
var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
|
|
8
|
-
var _isObject2 = _interopRequireDefault(require("lodash/isObject"));
|
|
9
|
-
var _defaults2 = _interopRequireDefault(require("lodash/defaults"));
|
|
10
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _defaults = _interopRequireDefault(require("lodash/defaults"));
|
|
9
|
+
var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
|
|
11
10
|
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
|
|
12
11
|
var UserProps = _interopRequireWildcard(require("../victory-util/user-props"));
|
|
13
12
|
var _clipPath = require("../victory-primitives/clip-path");
|
|
@@ -27,7 +26,20 @@ class VictoryClipContainer extends _react.default.Component {
|
|
|
27
26
|
};
|
|
28
27
|
constructor(props) {
|
|
29
28
|
super(props);
|
|
30
|
-
this.
|
|
29
|
+
this.state = {
|
|
30
|
+
clipId: props?.clipId
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// The clipId state is used to prevent hydration mismatches between the server and client (issue #2941).
|
|
35
|
+
// A better alternative would be to utilize React 18's useId hook instead of uniqueId, which would avoid needing state for this purpose.
|
|
36
|
+
// However, this component currently supports React 16 at the time of writing, so this workaround is necessary.
|
|
37
|
+
componentDidMount() {
|
|
38
|
+
if (!this.state.clipId) {
|
|
39
|
+
this.setState({
|
|
40
|
+
clipId: (0, _uniqueId.default)("victory-clip-")
|
|
41
|
+
});
|
|
42
|
+
}
|
|
31
43
|
}
|
|
32
44
|
calculateAttributes(props) {
|
|
33
45
|
const {
|
|
@@ -38,9 +50,7 @@ class VictoryClipContainer extends _react.default.Component {
|
|
|
38
50
|
translateX = 0,
|
|
39
51
|
translateY = 0
|
|
40
52
|
} = props;
|
|
41
|
-
const clipPadding = Helpers.getPadding(
|
|
42
|
-
padding: props.clipPadding
|
|
43
|
-
});
|
|
53
|
+
const clipPadding = Helpers.getPadding(props.clipPadding);
|
|
44
54
|
const radius = props.radius || Helpers.getRadius(props);
|
|
45
55
|
return {
|
|
46
56
|
x: (polar ? origin.x : translateX) - clipPadding.left,
|
|
@@ -109,9 +119,7 @@ class VictoryClipContainer extends _react.default.Component {
|
|
|
109
119
|
bottom,
|
|
110
120
|
left,
|
|
111
121
|
right
|
|
112
|
-
} = Helpers.getPadding(
|
|
113
|
-
padding: props.clipPadding
|
|
114
|
-
});
|
|
122
|
+
} = Helpers.getPadding(props.clipPadding);
|
|
115
123
|
let child;
|
|
116
124
|
if (polar) {
|
|
117
125
|
const radius = props.radius || Helpers.getRadius(props);
|
|
@@ -166,13 +174,13 @@ class VictoryClipContainer extends _react.default.Component {
|
|
|
166
174
|
}
|
|
167
175
|
const translateX = this.getTranslateValue(this.props, "x");
|
|
168
176
|
const translateY = this.getTranslateValue(this.props, "y");
|
|
169
|
-
const clipProps = (0,
|
|
177
|
+
const clipProps = (0, _defaults.default)({}, this.props, {
|
|
170
178
|
clipHeight,
|
|
171
179
|
clipWidth,
|
|
172
180
|
translateX,
|
|
173
181
|
translateY
|
|
174
182
|
});
|
|
175
|
-
return this.renderClippedGroup(clipProps, this.clipId);
|
|
183
|
+
return this.renderClippedGroup(clipProps, this.state.clipId);
|
|
176
184
|
}
|
|
177
185
|
}
|
|
178
186
|
exports.VictoryClipContainer = VictoryClipContainer;
|
|
@@ -5,16 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.VictoryContainer = void 0;
|
|
7
7
|
exports.useVictoryContainer = useVictoryContainer;
|
|
8
|
-
var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId"));
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
|
|
10
10
|
var _portal = require("../victory-portal/portal");
|
|
11
11
|
var UserProps = _interopRequireWildcard(require("../victory-util/user-props"));
|
|
12
12
|
var _victoryUtil = require("../victory-util");
|
|
13
13
|
var _portalOutlet = require("../victory-portal/portal-outlet");
|
|
14
14
|
var _portalContext = require("../victory-portal/portal-context");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
16
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
16
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
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); }
|
|
19
19
|
const defaultProps = {
|
|
20
20
|
className: "VictoryContainer",
|
|
@@ -38,7 +38,7 @@ function useVictoryContainer(initialProps) {
|
|
|
38
38
|
const localContainerRef = (0, _react.useRef)(null);
|
|
39
39
|
|
|
40
40
|
// Generated ID stored in ref because it needs to persist across renders
|
|
41
|
-
const generatedId = (0, _react.useRef)((0,
|
|
41
|
+
const generatedId = (0, _react.useRef)((0, _uniqueId.default)("victory-container-"));
|
|
42
42
|
const containerId = props.containerId ?? generatedId.current;
|
|
43
43
|
const getIdForElement = elName => `${containerId}-${elName}`;
|
|
44
44
|
const userProps = UserProps.getSafeUserProps(props);
|
|
@@ -113,9 +113,9 @@ const VictoryContainer = initialProps => {
|
|
|
113
113
|
...style,
|
|
114
114
|
width: responsive ? style?.width : dimensions.width,
|
|
115
115
|
height: responsive ? style?.height : dimensions.height,
|
|
116
|
-
pointerEvents: "none",
|
|
117
|
-
touchAction: "none",
|
|
118
|
-
position: "relative"
|
|
116
|
+
pointerEvents: style?.pointerEvents ?? "none",
|
|
117
|
+
touchAction: style?.touchAction ?? "none",
|
|
118
|
+
position: style?.position ?? "relative"
|
|
119
119
|
},
|
|
120
120
|
"data-ouia-component-id": ouiaId,
|
|
121
121
|
"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;
|