victory-chart 36.8.1 → 36.8.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.
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  export declare function getBackgroundWithProps(props: any, calculatedProps: any): React.DetailedReactHTMLElement<any, HTMLElement>;
3
- export declare function getCalculatedProps(props: any, childComponents: any): {
3
+ export declare function getCalculatedProps(initialProps: any, childComponents: any): {
4
4
  categories: {
5
5
  x: any;
6
6
  y: any;
@@ -84,12 +84,11 @@ function getStyles(props) {
84
84
  };
85
85
  }
86
86
 
87
- export function getCalculatedProps(props, childComponents) {
88
- var style = getStyles(props);
89
- props = Helpers.modifyProps(props, fallbackProps, "chart");
90
- var _props = props,
91
- horizontal = _props.horizontal,
92
- polar = _props.polar;
87
+ export function getCalculatedProps(initialProps, childComponents) {
88
+ var style = getStyles(initialProps);
89
+ var props = Helpers.modifyProps(initialProps, fallbackProps, "chart");
90
+ var horizontal = props.horizontal,
91
+ polar = props.polar;
93
92
  var allStrings = Wrapper.getStringsFromChildren(props, childComponents);
94
93
  var categories = Wrapper.getCategories(props, childComponents, allStrings);
95
94
  var stringMap = createStringMap(props, childComponents, allStrings);
@@ -128,23 +127,22 @@ export function getCalculatedProps(props, childComponents) {
128
127
  };
129
128
  }
130
129
  export function getChildren(props, childComponents, calculatedProps) {
131
- childComponents = childComponents || getChildComponents(props);
132
- calculatedProps = calculatedProps || getCalculatedProps(props, childComponents);
133
- var baseStyle = calculatedProps.style.parent;
130
+ var children = childComponents || getChildComponents(props);
131
+ var newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
132
+ var baseStyle = newCalculatedProps.style.parent;
134
133
  var height = props.height,
135
134
  polar = props.polar,
136
135
  theme = props.theme,
137
136
  width = props.width;
138
- var _calculatedProps = calculatedProps,
139
- origin = _calculatedProps.origin,
140
- horizontal = _calculatedProps.horizontal;
137
+ var origin = newCalculatedProps.origin,
138
+ horizontal = newCalculatedProps.horizontal;
141
139
  var parentName = props.name || "chart";
142
- return childComponents.filter(React.isValidElement).map(function (child, index) {
140
+ return children.filter(React.isValidElement).map(function (child, index) {
143
141
  var role = child.type && child.type.role;
144
142
  var style = Array.isArray(child.props.style) ? child.props.style : _defaults({}, child.props.style, {
145
143
  parent: baseStyle
146
144
  });
147
- var childProps = getChildProps(child, props, calculatedProps);
145
+ var childProps = getChildProps(child, props, newCalculatedProps);
148
146
  var name = child.props.name || "".concat(parentName, "-").concat(role, "-").concat(index);
149
147
 
150
148
  var newProps = _defaults({
@@ -156,7 +154,7 @@ export function getChildren(props, childComponents, calculatedProps) {
156
154
  style: style,
157
155
  name: name,
158
156
  origin: polar ? origin : undefined,
159
- padding: calculatedProps.padding,
157
+ padding: newCalculatedProps.padding,
160
158
  key: "".concat(name, "-key-").concat(index),
161
159
  standalone: false
162
160
  }, childProps);
@@ -184,9 +182,9 @@ export var getChildComponents = function (props, defaultAxes) {
184
182
  };
185
183
 
186
184
  var getDomain = function (props, axis, childComponents) {
187
- childComponents = childComponents || React.Children.toArray(props.children);
188
- var domain = Wrapper.getDomain(props, axis, childComponents);
189
- var axisComponent = Axis.getAxisComponent(childComponents, axis);
185
+ var children = childComponents || React.Children.toArray(props.children);
186
+ var domain = Wrapper.getDomain(props, axis, children);
187
+ var axisComponent = Axis.getAxisComponent(children, axis);
190
188
  var invertDomain = axisComponent && axisComponent.props && axisComponent.props.invertAxis;
191
189
  return invertDomain ? domain.concat().reverse() : domain;
192
190
  };
@@ -42,7 +42,9 @@ var defaultProps = {
42
42
  };
43
43
 
44
44
  var VictoryChartImpl = function (initialProps) {
45
- initialProps = _objectSpread(_objectSpread({}, defaultProps), initialProps);
45
+ var propsWithDefaults = React.useMemo(function () {
46
+ return _objectSpread(_objectSpread({}, defaultProps), initialProps);
47
+ }, [initialProps]);
46
48
  var role = "chart";
47
49
 
48
50
  var _Hooks$useAnimationSt = Hooks.useAnimationState(),
@@ -50,7 +52,7 @@ var VictoryChartImpl = function (initialProps) {
50
52
  setAnimationState = _Hooks$useAnimationSt.setAnimationState,
51
53
  getProps = _Hooks$useAnimationSt.getProps;
52
54
 
53
- var props = getProps(initialProps);
55
+ var props = getProps(propsWithDefaults);
54
56
  var modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
55
57
  var desc = modifiedProps.desc,
56
58
  eventKey = modifiedProps.eventKey,
@@ -116,25 +118,25 @@ var VictoryChartImpl = function (initialProps) {
116
118
  }, [desc, domain, height, horizontal, name, origin, polar, scale, standalone, style, title, theme, width]);
117
119
  var container = React.useMemo(function () {
118
120
  if (standalone) {
119
- var defaultContainerProps = _defaults({}, containerComponent.props, containerProps, UserProps.getSafeUserProps(initialProps));
121
+ var defaultContainerProps = _defaults({}, containerComponent.props, containerProps, UserProps.getSafeUserProps(propsWithDefaults));
120
122
 
121
123
  return /*#__PURE__*/React.cloneElement(containerComponent, defaultContainerProps);
122
124
  }
123
125
 
124
126
  return groupComponent;
125
- }, [groupComponent, standalone, containerComponent, containerProps, initialProps]);
127
+ }, [groupComponent, standalone, containerComponent, containerProps, propsWithDefaults]);
126
128
  var events = React.useMemo(function () {
127
129
  return Wrapper.getAllEvents(props);
128
130
  }, [props]);
129
- var previousProps = Hooks.usePreviousProps(initialProps);
131
+ var previousProps = Hooks.usePreviousProps(propsWithDefaults);
130
132
  React.useEffect(function () {
131
133
  // This is called before dismount to keep state in sync
132
134
  return function () {
133
- if (initialProps.animate) {
134
- setAnimationState(previousProps, initialProps);
135
+ if (propsWithDefaults.animate) {
136
+ setAnimationState(previousProps, propsWithDefaults);
135
137
  }
136
138
  };
137
- }, [setAnimationState, previousProps, initialProps]);
139
+ }, [setAnimationState, previousProps, propsWithDefaults]);
138
140
 
139
141
  if (!_isEmpty(events)) {
140
142
  return /*#__PURE__*/React.createElement(VictorySharedEvents, {
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  export declare function getBackgroundWithProps(props: any, calculatedProps: any): React.DetailedReactHTMLElement<any, HTMLElement>;
3
- export declare function getCalculatedProps(props: any, childComponents: any): {
3
+ export declare function getCalculatedProps(initialProps: any, childComponents: any): {
4
4
  categories: {
5
5
  x: any;
6
6
  y: any;
@@ -99,12 +99,13 @@ function getStyles(props) {
99
99
  };
100
100
  }
101
101
 
102
- function getCalculatedProps(props, childComponents) {
103
- var style = getStyles(props);
104
- props = _victoryCore.Helpers.modifyProps(props, fallbackProps, "chart");
105
- var _props = props,
106
- horizontal = _props.horizontal,
107
- polar = _props.polar;
102
+ function getCalculatedProps(initialProps, childComponents) {
103
+ var style = getStyles(initialProps);
104
+
105
+ var props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "chart");
106
+
107
+ var horizontal = props.horizontal,
108
+ polar = props.polar;
108
109
 
109
110
  var allStrings = _victoryCore.Wrapper.getStringsFromChildren(props, childComponents);
110
111
 
@@ -149,23 +150,22 @@ function getCalculatedProps(props, childComponents) {
149
150
  }
150
151
 
151
152
  function getChildren(props, childComponents, calculatedProps) {
152
- childComponents = childComponents || getChildComponents(props);
153
- calculatedProps = calculatedProps || getCalculatedProps(props, childComponents);
154
- var baseStyle = calculatedProps.style.parent;
153
+ var children = childComponents || getChildComponents(props);
154
+ var newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
155
+ var baseStyle = newCalculatedProps.style.parent;
155
156
  var height = props.height,
156
157
  polar = props.polar,
157
158
  theme = props.theme,
158
159
  width = props.width;
159
- var _calculatedProps = calculatedProps,
160
- origin = _calculatedProps.origin,
161
- horizontal = _calculatedProps.horizontal;
160
+ var origin = newCalculatedProps.origin,
161
+ horizontal = newCalculatedProps.horizontal;
162
162
  var parentName = props.name || "chart";
163
- return childComponents.filter(_react.default.isValidElement).map(function (child, index) {
163
+ return children.filter(_react.default.isValidElement).map(function (child, index) {
164
164
  var role = child.type && child.type.role;
165
165
  var style = Array.isArray(child.props.style) ? child.props.style : (0, _defaults2.default)({}, child.props.style, {
166
166
  parent: baseStyle
167
167
  });
168
- var childProps = getChildProps(child, props, calculatedProps);
168
+ var childProps = getChildProps(child, props, newCalculatedProps);
169
169
  var name = child.props.name || "".concat(parentName, "-").concat(role, "-").concat(index);
170
170
  var newProps = (0, _defaults2.default)({
171
171
  horizontal: horizontal,
@@ -176,7 +176,7 @@ function getChildren(props, childComponents, calculatedProps) {
176
176
  style: style,
177
177
  name: name,
178
178
  origin: polar ? origin : undefined,
179
- padding: calculatedProps.padding,
179
+ padding: newCalculatedProps.padding,
180
180
  key: "".concat(name, "-key-").concat(index),
181
181
  standalone: false
182
182
  }, childProps);
@@ -206,11 +206,11 @@ var getChildComponents = function (props, defaultAxes) {
206
206
  exports.getChildComponents = getChildComponents;
207
207
 
208
208
  var getDomain = function (props, axis, childComponents) {
209
- childComponents = childComponents || _react.default.Children.toArray(props.children);
209
+ var children = childComponents || _react.default.Children.toArray(props.children);
210
210
 
211
- var domain = _victoryCore.Wrapper.getDomain(props, axis, childComponents);
211
+ var domain = _victoryCore.Wrapper.getDomain(props, axis, children);
212
212
 
213
- var axisComponent = _victoryCore.Axis.getAxisComponent(childComponents, axis);
213
+ var axisComponent = _victoryCore.Axis.getAxisComponent(children, axis);
214
214
 
215
215
  var invertDomain = axisComponent && axisComponent.props && axisComponent.props.invertAxis;
216
216
  return invertDomain ? domain.concat().reverse() : domain;
@@ -61,7 +61,10 @@ var defaultProps = {
61
61
  };
62
62
 
63
63
  var VictoryChartImpl = function (initialProps) {
64
- initialProps = _objectSpread(_objectSpread({}, defaultProps), initialProps);
64
+ var propsWithDefaults = _react.default.useMemo(function () {
65
+ return _objectSpread(_objectSpread({}, defaultProps), initialProps);
66
+ }, [initialProps]);
67
+
65
68
  var role = "chart";
66
69
 
67
70
  var _Hooks$useAnimationSt = _victoryCore.Hooks.useAnimationState(),
@@ -69,7 +72,7 @@ var VictoryChartImpl = function (initialProps) {
69
72
  setAnimationState = _Hooks$useAnimationSt.setAnimationState,
70
73
  getProps = _Hooks$useAnimationSt.getProps;
71
74
 
72
- var props = getProps(initialProps);
75
+ var props = getProps(propsWithDefaults);
73
76
 
74
77
  var modifiedProps = _victoryCore.Helpers.modifyProps(props, fallbackProps, role);
75
78
 
@@ -142,27 +145,27 @@ var VictoryChartImpl = function (initialProps) {
142
145
 
143
146
  var container = _react.default.useMemo(function () {
144
147
  if (standalone) {
145
- var defaultContainerProps = (0, _defaults2.default)({}, containerComponent.props, containerProps, _victoryCore.UserProps.getSafeUserProps(initialProps));
148
+ var defaultContainerProps = (0, _defaults2.default)({}, containerComponent.props, containerProps, _victoryCore.UserProps.getSafeUserProps(propsWithDefaults));
146
149
  return /*#__PURE__*/_react.default.cloneElement(containerComponent, defaultContainerProps);
147
150
  }
148
151
 
149
152
  return groupComponent;
150
- }, [groupComponent, standalone, containerComponent, containerProps, initialProps]);
153
+ }, [groupComponent, standalone, containerComponent, containerProps, propsWithDefaults]);
151
154
 
152
155
  var events = _react.default.useMemo(function () {
153
156
  return _victoryCore.Wrapper.getAllEvents(props);
154
157
  }, [props]);
155
158
 
156
- var previousProps = _victoryCore.Hooks.usePreviousProps(initialProps);
159
+ var previousProps = _victoryCore.Hooks.usePreviousProps(propsWithDefaults);
157
160
 
158
161
  _react.default.useEffect(function () {
159
162
  // This is called before dismount to keep state in sync
160
163
  return function () {
161
- if (initialProps.animate) {
162
- setAnimationState(previousProps, initialProps);
164
+ if (propsWithDefaults.animate) {
165
+ setAnimationState(previousProps, propsWithDefaults);
163
166
  }
164
167
  };
165
- }, [setAnimationState, previousProps, initialProps]);
168
+ }, [setAnimationState, previousProps, propsWithDefaults]);
166
169
 
167
170
  if (!(0, _isEmpty2.default)(events)) {
168
171
  return /*#__PURE__*/_react.default.createElement(_victorySharedEvents.VictorySharedEvents, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-chart",
3
- "version": "36.8.1",
3
+ "version": "36.8.3",
4
4
  "description": "Chart Component for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -23,10 +23,10 @@
23
23
  "lodash": "^4.17.19",
24
24
  "prop-types": "^15.8.1",
25
25
  "react-fast-compare": "^3.2.0",
26
- "victory-axis": "^36.8.1",
27
- "victory-core": "^36.8.1",
28
- "victory-polar-axis": "^36.8.1",
29
- "victory-shared-events": "^36.8.1"
26
+ "victory-axis": "^36.8.3",
27
+ "victory-core": "^36.8.3",
28
+ "victory-polar-axis": "^36.8.3",
29
+ "victory-shared-events": "^36.8.3"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=16.6.0"
@@ -82,9 +82,9 @@ function getStyles(props) {
82
82
  };
83
83
  }
84
84
 
85
- export function getCalculatedProps(props, childComponents) {
86
- const style = getStyles(props);
87
- props = Helpers.modifyProps(props, fallbackProps, "chart");
85
+ export function getCalculatedProps(initialProps, childComponents) {
86
+ const style = getStyles(initialProps);
87
+ const props = Helpers.modifyProps(initialProps, fallbackProps, "chart");
88
88
  const { horizontal, polar } = props;
89
89
  const allStrings = Wrapper.getStringsFromChildren(props, childComponents);
90
90
  const categories = Wrapper.getCategories(props, childComponents, allStrings);
@@ -125,20 +125,20 @@ export function getCalculatedProps(props, childComponents) {
125
125
  }
126
126
 
127
127
  export function getChildren(props, childComponents, calculatedProps) {
128
- childComponents = childComponents || getChildComponents(props);
129
- calculatedProps =
130
- calculatedProps || getCalculatedProps(props, childComponents);
131
- const baseStyle = calculatedProps.style.parent;
128
+ const children = childComponents || getChildComponents(props);
129
+ const newCalculatedProps =
130
+ calculatedProps || getCalculatedProps(props, children);
131
+ const baseStyle = newCalculatedProps.style.parent;
132
132
  const { height, polar, theme, width } = props;
133
- const { origin, horizontal } = calculatedProps;
133
+ const { origin, horizontal } = newCalculatedProps;
134
134
  const parentName = props.name || "chart";
135
135
 
136
- return childComponents.filter(React.isValidElement).map((child, index) => {
136
+ return children.filter(React.isValidElement).map((child, index) => {
137
137
  const role = child.type && child.type.role;
138
138
  const style = Array.isArray(child.props.style)
139
139
  ? child.props.style
140
140
  : defaults({}, child.props.style, { parent: baseStyle });
141
- const childProps = getChildProps(child, props, calculatedProps);
141
+ const childProps = getChildProps(child, props, newCalculatedProps);
142
142
  const name = child.props.name || `${parentName}-${role}-${index}`;
143
143
  const newProps = defaults(
144
144
  {
@@ -150,7 +150,7 @@ export function getChildren(props, childComponents, calculatedProps) {
150
150
  style,
151
151
  name,
152
152
  origin: polar ? origin : undefined,
153
- padding: calculatedProps.padding,
153
+ padding: newCalculatedProps.padding,
154
154
  key: `${name}-key-${index}`,
155
155
  standalone: false,
156
156
  },
@@ -193,9 +193,9 @@ export const getChildComponents = (props, defaultAxes?) => {
193
193
  };
194
194
 
195
195
  const getDomain = (props, axis, childComponents) => {
196
- childComponents = childComponents || React.Children.toArray(props.children);
197
- const domain = Wrapper.getDomain(props, axis, childComponents);
198
- const axisComponent = Axis.getAxisComponent(childComponents, axis);
196
+ const children = childComponents || React.Children.toArray(props.children);
197
+ const domain = Wrapper.getDomain(props, axis, children);
198
+ const axisComponent = Axis.getAxisComponent(children, axis);
199
199
  const invertDomain =
200
200
  axisComponent && axisComponent.props && axisComponent.props.invertAxis;
201
201
  return invertDomain ? domain.concat().reverse() : domain;
@@ -53,11 +53,14 @@ const defaultProps = {
53
53
  };
54
54
 
55
55
  const VictoryChartImpl: React.FC<VictoryChartProps> = (initialProps) => {
56
- initialProps = { ...defaultProps, ...initialProps };
56
+ const propsWithDefaults = React.useMemo(
57
+ () => ({ ...defaultProps, ...initialProps }),
58
+ [initialProps],
59
+ );
57
60
  const role = "chart";
58
61
  const { getAnimationProps, setAnimationState, getProps } =
59
62
  Hooks.useAnimationState();
60
- const props = getProps(initialProps);
63
+ const props = getProps(propsWithDefaults);
61
64
 
62
65
  const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
63
66
  const {
@@ -154,7 +157,7 @@ const VictoryChartImpl: React.FC<VictoryChartProps> = (initialProps) => {
154
157
  {},
155
158
  containerComponent.props,
156
159
  containerProps,
157
- UserProps.getSafeUserProps(initialProps),
160
+ UserProps.getSafeUserProps(propsWithDefaults),
158
161
  );
159
162
  return React.cloneElement(containerComponent, defaultContainerProps);
160
163
  }
@@ -164,23 +167,23 @@ const VictoryChartImpl: React.FC<VictoryChartProps> = (initialProps) => {
164
167
  standalone,
165
168
  containerComponent,
166
169
  containerProps,
167
- initialProps,
170
+ propsWithDefaults,
168
171
  ]);
169
172
 
170
173
  const events = React.useMemo(() => {
171
174
  return Wrapper.getAllEvents(props);
172
175
  }, [props]);
173
176
 
174
- const previousProps = Hooks.usePreviousProps(initialProps);
177
+ const previousProps = Hooks.usePreviousProps(propsWithDefaults);
175
178
 
176
179
  React.useEffect(() => {
177
180
  // This is called before dismount to keep state in sync
178
181
  return () => {
179
- if (initialProps.animate) {
180
- setAnimationState(previousProps, initialProps);
182
+ if (propsWithDefaults.animate) {
183
+ setAnimationState(previousProps, propsWithDefaults);
181
184
  }
182
185
  };
183
- }, [setAnimationState, previousProps, initialProps]);
186
+ }, [setAnimationState, previousProps, propsWithDefaults]);
184
187
 
185
188
  if (!isEmpty(events)) {
186
189
  return (