victory-errorbar 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/src/error-bar.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable max-statements */
2
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
- import { Helpers, CommonProps, Line } from "victory-core";
4
+ import { Helpers, CommonProps, Line, UserProps } from "victory-core";
5
5
  import { assign } from "lodash";
6
6
 
7
7
  const renderBorder = (props, error, type) => {
@@ -17,7 +17,8 @@ const renderBorder = (props, error, type) => {
17
17
  x1: vertical ? error[type] : props.x - props.borderWidth,
18
18
  x2: vertical ? error[type] : props.x + props.borderWidth,
19
19
  y1: vertical ? props.y - props.borderWidth : error[type],
20
- y2: vertical ? props.y + props.borderWidth : error[type]
20
+ y2: vertical ? props.y + props.borderWidth : error[type],
21
+ "data-type": `border-${type}`
21
22
  });
22
23
  };
23
24
 
@@ -34,7 +35,8 @@ const renderCross = (props, error, type) => {
34
35
  x1: props.x,
35
36
  x2: vertical ? props.x : error[type],
36
37
  y1: props.y,
37
- y2: vertical ? error[type] : props.y
38
+ y2: vertical ? error[type] : props.y,
39
+ "data-type": `cross-${type}`
38
40
  });
39
41
  };
40
42
 
@@ -80,7 +82,8 @@ const evaluateProps = (props) => {
80
82
 
81
83
  const ErrorBar = (props) => {
82
84
  props = evaluateProps(props);
83
- const { ariaLabel, tabIndex } = props;
85
+ const userProps = UserProps.getSafeUserProps(props);
86
+ const { tabIndex, ariaLabel } = props;
84
87
  const error = calculateError(props);
85
88
  const children = [
86
89
  error.right ? renderBorder(props, error, "right") : null,
@@ -94,7 +97,7 @@ const ErrorBar = (props) => {
94
97
  ].filter(Boolean);
95
98
  return React.cloneElement(
96
99
  props.groupComponent,
97
- { "aria-label": ariaLabel, tabIndex },
100
+ { tabIndex, "aria-label": ariaLabel, ...userProps },
98
101
  children
99
102
  );
100
103
  };
@@ -106,13 +106,12 @@ class VictoryErrorBar extends React.Component {
106
106
  }
107
107
 
108
108
  const children = this.renderData(props);
109
- const container = React.cloneElement(
110
- props.containerComponent,
111
- UserProps.getSafeUserProps(props)
112
- );
113
- return props.standalone
114
- ? this.renderContainer(container, children)
109
+
110
+ const component = props.standalone
111
+ ? this.renderContainer(props.containerComponent, children)
115
112
  : children;
113
+
114
+ return UserProps.withSafeUserProps(component, props);
116
115
  }
117
116
  }
118
117