victory-stack 36.9.2 → 37.0.1-next.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/CHANGELOG.md +13 -0
- package/dist/victory-stack.js +2486 -3379
- package/dist/victory-stack.min.js +1 -1
- package/es/helper-methods.d.ts +52 -52
- package/es/helper-methods.js +116 -162
- package/es/index.d.ts +1 -1
- package/es/victory-stack.d.ts +18 -18
- package/es/victory-stack.js +61 -72
- package/lib/helper-methods.d.ts +52 -52
- package/lib/helper-methods.js +116 -178
- package/lib/index.d.ts +1 -1
- package/lib/index.js +0 -2
- package/lib/victory-stack.d.ts +18 -18
- package/lib/victory-stack.js +60 -91
- package/package.json +5 -8
package/es/victory-stack.js
CHANGED
|
@@ -1,63 +1,61 @@
|
|
|
1
1
|
import _isEmpty from "lodash/isEmpty";
|
|
2
2
|
import _defaults from "lodash/defaults";
|
|
3
|
-
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
-
|
|
8
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
-
|
|
10
3
|
import React from "react";
|
|
11
4
|
import { Helpers, Hooks, UserProps, VictoryContainer, VictoryTheme, Wrapper } from "victory-core";
|
|
12
5
|
import { VictorySharedEvents } from "victory-shared-events";
|
|
13
6
|
import { getChildren, useMemoizedProps } from "./helper-methods";
|
|
14
7
|
import isEqual from "react-fast-compare";
|
|
15
|
-
|
|
8
|
+
const fallbackProps = {
|
|
16
9
|
width: 450,
|
|
17
10
|
height: 300,
|
|
18
11
|
padding: 50
|
|
19
12
|
};
|
|
20
|
-
|
|
13
|
+
const defaultProps = {
|
|
21
14
|
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
|
|
22
15
|
groupComponent: /*#__PURE__*/React.createElement("g", null),
|
|
23
16
|
standalone: true,
|
|
24
17
|
theme: VictoryTheme.grayscale,
|
|
25
18
|
fillInMissingData: true
|
|
26
19
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
20
|
+
const VictoryStackBase = initialProps => {
|
|
21
|
+
const {
|
|
22
|
+
role
|
|
23
|
+
} = VictoryStack;
|
|
24
|
+
const propsWithDefaults = React.useMemo(() => ({
|
|
25
|
+
...defaultProps,
|
|
26
|
+
...initialProps
|
|
27
|
+
}), [initialProps]);
|
|
28
|
+
const {
|
|
29
|
+
setAnimationState,
|
|
30
|
+
getAnimationProps,
|
|
31
|
+
getProps
|
|
32
|
+
} = Hooks.useAnimationState();
|
|
33
|
+
const props = getProps(propsWithDefaults);
|
|
34
|
+
const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
|
|
35
|
+
const {
|
|
36
|
+
eventKey,
|
|
37
|
+
containerComponent,
|
|
38
|
+
standalone,
|
|
39
|
+
groupComponent,
|
|
40
|
+
externalEventMutations,
|
|
41
|
+
width,
|
|
42
|
+
height,
|
|
43
|
+
theme,
|
|
44
|
+
polar,
|
|
45
|
+
horizontal,
|
|
46
|
+
name
|
|
47
|
+
} = modifiedProps;
|
|
48
|
+
const childComponents = React.Children.toArray(modifiedProps.children);
|
|
49
|
+
const calculatedProps = useMemoizedProps(modifiedProps);
|
|
50
|
+
const {
|
|
51
|
+
domain,
|
|
52
|
+
scale,
|
|
53
|
+
style
|
|
54
|
+
} = calculatedProps;
|
|
55
|
+
const newChildren = React.useMemo(() => {
|
|
56
|
+
const children = getChildren(props, childComponents, calculatedProps);
|
|
57
|
+
const orderedChildren = children.map((child, index) => {
|
|
58
|
+
const childProps = Object.assign({
|
|
61
59
|
animate: getAnimationProps(props, child, index)
|
|
62
60
|
}, child.props);
|
|
63
61
|
return /*#__PURE__*/React.cloneElement(child, childProps);
|
|
@@ -67,52 +65,45 @@ var VictoryStackBase = function (initialProps) {
|
|
|
67
65
|
are rendered behind lower children. This looks nicer for stacked bars with cornerRadius, and
|
|
68
66
|
areas with strokes
|
|
69
67
|
*/
|
|
70
|
-
|
|
71
68
|
return orderedChildren.reverse();
|
|
72
69
|
}, [props, childComponents, calculatedProps, getAnimationProps]);
|
|
73
|
-
|
|
70
|
+
const containerProps = React.useMemo(() => {
|
|
74
71
|
if (standalone) {
|
|
75
72
|
return {
|
|
76
|
-
domain
|
|
77
|
-
scale
|
|
78
|
-
width
|
|
79
|
-
height
|
|
80
|
-
standalone
|
|
81
|
-
theme
|
|
73
|
+
domain,
|
|
74
|
+
scale,
|
|
75
|
+
width,
|
|
76
|
+
height,
|
|
77
|
+
standalone,
|
|
78
|
+
theme,
|
|
82
79
|
style: style.parent,
|
|
83
|
-
horizontal
|
|
84
|
-
polar
|
|
85
|
-
name
|
|
80
|
+
horizontal,
|
|
81
|
+
polar,
|
|
82
|
+
name
|
|
86
83
|
};
|
|
87
84
|
}
|
|
88
|
-
|
|
89
85
|
return {};
|
|
90
86
|
}, [standalone, domain, scale, width, height, theme, style, horizontal, polar, name]);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}, [propsWithDefaults]);
|
|
94
|
-
var container = React.useMemo(function () {
|
|
87
|
+
const userProps = React.useMemo(() => UserProps.getSafeUserProps(propsWithDefaults), [propsWithDefaults]);
|
|
88
|
+
const container = React.useMemo(() => {
|
|
95
89
|
if (standalone) {
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
const defaultContainerProps = _defaults({}, containerComponent.props, containerProps, userProps);
|
|
98
91
|
return /*#__PURE__*/React.cloneElement(containerComponent, defaultContainerProps);
|
|
99
92
|
}
|
|
100
|
-
|
|
101
93
|
return /*#__PURE__*/React.cloneElement(groupComponent, userProps);
|
|
102
94
|
}, [groupComponent, standalone, containerComponent, containerProps, userProps]);
|
|
103
|
-
|
|
95
|
+
const events = React.useMemo(() => {
|
|
104
96
|
return Wrapper.getAllEvents(props);
|
|
105
97
|
}, [props]);
|
|
106
|
-
|
|
107
|
-
React.useEffect(
|
|
98
|
+
const previousProps = Hooks.usePreviousProps(propsWithDefaults);
|
|
99
|
+
React.useEffect(() => {
|
|
108
100
|
// This is called before dismount to keep state in sync
|
|
109
|
-
return
|
|
101
|
+
return () => {
|
|
110
102
|
if (propsWithDefaults.animate) {
|
|
111
103
|
setAnimationState(previousProps, propsWithDefaults);
|
|
112
104
|
}
|
|
113
105
|
};
|
|
114
106
|
}, [setAnimationState, previousProps, propsWithDefaults]);
|
|
115
|
-
|
|
116
107
|
if (!_isEmpty(events)) {
|
|
117
108
|
return /*#__PURE__*/React.createElement(VictorySharedEvents, {
|
|
118
109
|
container: container,
|
|
@@ -121,14 +112,12 @@ var VictoryStackBase = function (initialProps) {
|
|
|
121
112
|
externalEventMutations: externalEventMutations
|
|
122
113
|
}, newChildren);
|
|
123
114
|
}
|
|
124
|
-
|
|
125
115
|
return /*#__PURE__*/React.cloneElement(container, container.props, newChildren);
|
|
126
116
|
};
|
|
127
|
-
|
|
128
|
-
var componentConfig = {
|
|
117
|
+
const componentConfig = {
|
|
129
118
|
role: "stack",
|
|
130
119
|
expectedComponents: ["groupComponent", "containerComponent", "labelComponent"],
|
|
131
|
-
getChildren
|
|
120
|
+
getChildren
|
|
132
121
|
};
|
|
133
|
-
export
|
|
122
|
+
export const VictoryStack = Object.assign( /*#__PURE__*/React.memo(VictoryStackBase, isEqual), componentConfig);
|
|
134
123
|
VictoryStack.displayName = "VictoryStack";
|
package/lib/helper-methods.d.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
export declare function getCalculatedProps(initialProps: any, childComponents: any): {
|
|
2
|
-
datasets: any;
|
|
3
|
-
categories: any;
|
|
4
|
-
range: any;
|
|
5
|
-
domain: {
|
|
6
|
-
x: any;
|
|
7
|
-
y: any;
|
|
8
|
-
};
|
|
9
|
-
horizontal: any;
|
|
10
|
-
scale: {
|
|
11
|
-
x: import("victory-core").D3Scale<any>;
|
|
12
|
-
y: import("victory-core").D3Scale<any>;
|
|
13
|
-
};
|
|
14
|
-
style: any;
|
|
15
|
-
colorScale: any;
|
|
16
|
-
role: string;
|
|
17
|
-
};
|
|
18
|
-
export declare function useMemoizedProps(initialProps: any): {
|
|
19
|
-
datasets: any;
|
|
20
|
-
categories: any;
|
|
21
|
-
range: any;
|
|
22
|
-
domain: {
|
|
23
|
-
x: any;
|
|
24
|
-
y: any;
|
|
25
|
-
};
|
|
26
|
-
horizontal: any;
|
|
27
|
-
scale: {
|
|
28
|
-
x: import("victory-core").D3Scale<any>;
|
|
29
|
-
y: import("victory-core").D3Scale<any>;
|
|
30
|
-
};
|
|
31
|
-
style: any;
|
|
32
|
-
colorScale: any;
|
|
33
|
-
role: string;
|
|
34
|
-
};
|
|
35
|
-
export declare function getChildProps(props: any, calculatedProps: any): {
|
|
36
|
-
height: any;
|
|
37
|
-
width: any;
|
|
38
|
-
padding: {
|
|
39
|
-
top: any;
|
|
40
|
-
bottom: any;
|
|
41
|
-
left: any;
|
|
42
|
-
right: any;
|
|
43
|
-
};
|
|
44
|
-
standalone: boolean;
|
|
45
|
-
theme: any;
|
|
46
|
-
categories: any;
|
|
47
|
-
domain: any;
|
|
48
|
-
range: any;
|
|
49
|
-
scale: any;
|
|
50
|
-
horizontal: any;
|
|
51
|
-
};
|
|
52
|
-
export declare function getChildren(initialProps: any, childComponents: any, calculatedProps: any): any;
|
|
1
|
+
export declare function getCalculatedProps(initialProps: any, childComponents: any): {
|
|
2
|
+
datasets: any;
|
|
3
|
+
categories: any;
|
|
4
|
+
range: any;
|
|
5
|
+
domain: {
|
|
6
|
+
x: any;
|
|
7
|
+
y: any;
|
|
8
|
+
};
|
|
9
|
+
horizontal: any;
|
|
10
|
+
scale: {
|
|
11
|
+
x: import("victory-core").D3Scale<any>;
|
|
12
|
+
y: import("victory-core").D3Scale<any>;
|
|
13
|
+
};
|
|
14
|
+
style: any;
|
|
15
|
+
colorScale: any;
|
|
16
|
+
role: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function useMemoizedProps(initialProps: any): {
|
|
19
|
+
datasets: any;
|
|
20
|
+
categories: any;
|
|
21
|
+
range: any;
|
|
22
|
+
domain: {
|
|
23
|
+
x: any;
|
|
24
|
+
y: any;
|
|
25
|
+
};
|
|
26
|
+
horizontal: any;
|
|
27
|
+
scale: {
|
|
28
|
+
x: import("victory-core").D3Scale<any>;
|
|
29
|
+
y: import("victory-core").D3Scale<any>;
|
|
30
|
+
};
|
|
31
|
+
style: any;
|
|
32
|
+
colorScale: any;
|
|
33
|
+
role: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function getChildProps(props: any, calculatedProps: any): {
|
|
36
|
+
height: any;
|
|
37
|
+
width: any;
|
|
38
|
+
padding: {
|
|
39
|
+
top: any;
|
|
40
|
+
bottom: any;
|
|
41
|
+
left: any;
|
|
42
|
+
right: any;
|
|
43
|
+
};
|
|
44
|
+
standalone: boolean;
|
|
45
|
+
theme: any;
|
|
46
|
+
categories: any;
|
|
47
|
+
domain: any;
|
|
48
|
+
range: any;
|
|
49
|
+
scale: any;
|
|
50
|
+
horizontal: any;
|
|
51
|
+
};
|
|
52
|
+
export declare function getChildren(initialProps: any, childComponents: any, calculatedProps: any): any;
|
|
53
53
|
//# sourceMappingURL=helper-methods.d.ts.map
|