victory-core 36.4.0 → 36.4.1
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/dist/victory-core.js +765 -678
- package/dist/victory-core.min.js +1 -1
- package/es/victory-clip-container/victory-clip-container.js +3 -2
- package/es/victory-label/victory-label.js +3 -1
- package/es/victory-util/add-events.js +1 -4
- package/es/victory-util/common-props.js +2 -2
- package/es/victory-util/user-props.js +13 -0
- package/lib/victory-clip-container/victory-clip-container.js +4 -2
- package/lib/victory-label/victory-label.js +4 -1
- package/lib/victory-util/add-events.js +1 -7
- package/lib/victory-util/common-props.js +2 -2
- package/lib/victory-util/user-props.js +22 -2
- package/package.json +4 -4
- package/src/victory-clip-container/victory-clip-container.js +3 -1
- package/src/victory-label/victory-label.js +5 -1
- package/src/victory-util/add-events.js +1 -4
- package/src/victory-util/common-props.js +2 -2
- package/src/victory-util/user-props.js +13 -0
|
@@ -45,6 +45,7 @@ import React from "react";
|
|
|
45
45
|
import PropTypes from "prop-types";
|
|
46
46
|
import * as CustomPropTypes from "../victory-util/prop-types";
|
|
47
47
|
import * as Helpers from "../victory-util/helpers";
|
|
48
|
+
import * as UserProps from "../victory-util/user-props";
|
|
48
49
|
import ClipPath from "../victory-primitives/clip-path";
|
|
49
50
|
import Circle from "../victory-primitives/circle";
|
|
50
51
|
import Rect from "../victory-primitives/rect";
|
|
@@ -91,6 +92,7 @@ var VictoryClipContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
91
92
|
}, {
|
|
92
93
|
key: "renderClippedGroup",
|
|
93
94
|
value: function renderClippedGroup(props, clipId) {
|
|
95
|
+
var userProps = UserProps.getSafeUserProps(props);
|
|
94
96
|
var style = props.style,
|
|
95
97
|
events = props.events,
|
|
96
98
|
transform = props.transform,
|
|
@@ -109,9 +111,8 @@ var VictoryClipContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
109
111
|
}, events);
|
|
110
112
|
|
|
111
113
|
return /*#__PURE__*/React.cloneElement(groupComponent, _objectSpread(_objectSpread({}, groupProps), {}, {
|
|
112
|
-
"aria-label": props["aria-label"],
|
|
113
114
|
tabIndex: tabIndex
|
|
114
|
-
}), [clipComponent].concat(_toConsumableArray(React.Children.toArray(children))));
|
|
115
|
+
}, userProps), [clipComponent].concat(_toConsumableArray(React.Children.toArray(children))));
|
|
115
116
|
}
|
|
116
117
|
}, {
|
|
117
118
|
key: "renderGroup",
|
|
@@ -32,6 +32,7 @@ import * as Log from "../victory-util/log";
|
|
|
32
32
|
import * as CustomPropTypes from "../victory-util/prop-types";
|
|
33
33
|
import * as Style from "../victory-util/style";
|
|
34
34
|
import * as TextSize from "../victory-util/textsize";
|
|
35
|
+
import * as UserProps from "../victory-util/user-props";
|
|
35
36
|
var defaultStyles = {
|
|
36
37
|
fill: "#252525",
|
|
37
38
|
fontSize: 14,
|
|
@@ -468,6 +469,7 @@ var renderLabel = function (calculatedProps, tspanValues) {
|
|
|
468
469
|
tabIndex = calculatedProps.tabIndex,
|
|
469
470
|
tspanComponent = calculatedProps.tspanComponent,
|
|
470
471
|
textComponent = calculatedProps.textComponent;
|
|
472
|
+
var userProps = UserProps.getSafeUserProps(calculatedProps);
|
|
471
473
|
|
|
472
474
|
var textProps = _objectSpread(_objectSpread({
|
|
473
475
|
"aria-label": ariaLabel,
|
|
@@ -483,7 +485,7 @@ var renderLabel = function (calculatedProps, tspanValues) {
|
|
|
483
485
|
desc: Helpers.evaluateProp(desc, calculatedProps),
|
|
484
486
|
tabIndex: Helpers.evaluateProp(tabIndex, calculatedProps),
|
|
485
487
|
id: id
|
|
486
|
-
});
|
|
488
|
+
}, userProps);
|
|
487
489
|
|
|
488
490
|
var tspans = text.map(function (line, i) {
|
|
489
491
|
var currentStyle = tspanValues[i].style;
|
|
@@ -45,7 +45,6 @@ import React from "react";
|
|
|
45
45
|
import * as Events from "./events";
|
|
46
46
|
import isEqual from "react-fast-compare";
|
|
47
47
|
import VictoryTransition from "../victory-transition/victory-transition";
|
|
48
|
-
import * as UserProps from "../victory-util/user-props";
|
|
49
48
|
|
|
50
49
|
var datumHasXandY = function (datum) {
|
|
51
50
|
return !_isNil(datum._x) && !_isNil(datum._y);
|
|
@@ -392,7 +391,6 @@ export default (function (WrappedComponent, options) {
|
|
|
392
391
|
var dataComponent = props.dataComponent,
|
|
393
392
|
labelComponent = props.labelComponent,
|
|
394
393
|
groupComponent = props.groupComponent;
|
|
395
|
-
var userProps = UserProps.getSafeUserProps(props);
|
|
396
394
|
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
|
|
397
395
|
var dataProps = _this9.getComponentProps(dataComponent, "data", index);
|
|
398
396
|
|
|
@@ -412,8 +410,7 @@ export default (function (WrappedComponent, options) {
|
|
|
412
410
|
return undefined;
|
|
413
411
|
}).filter(Boolean);
|
|
414
412
|
var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents));
|
|
415
|
-
|
|
416
|
-
return this.renderContainer(group, children);
|
|
413
|
+
return this.renderContainer(groupComponent, children);
|
|
417
414
|
}
|
|
418
415
|
}]);
|
|
419
416
|
|
|
@@ -48,10 +48,10 @@ export var baseProps = {
|
|
|
48
48
|
eventHandlers: PropTypes.object
|
|
49
49
|
})),
|
|
50
50
|
externalEventMutations: PropTypes.arrayOf(PropTypes.shape({
|
|
51
|
-
callback: PropTypes.
|
|
51
|
+
callback: PropTypes.func,
|
|
52
52
|
childName: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
53
53
|
eventKey: PropTypes.oneOfType([PropTypes.array, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), PropTypes.string]),
|
|
54
|
-
mutation: PropTypes.
|
|
54
|
+
mutation: PropTypes.func,
|
|
55
55
|
target: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
|
|
56
56
|
})),
|
|
57
57
|
groupComponent: PropTypes.element,
|
|
@@ -16,12 +16,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
|
|
17
17
|
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; }
|
|
18
18
|
|
|
19
|
+
import * as React from "react";
|
|
19
20
|
/*
|
|
20
21
|
USER_PROPS_SAFELIST is to contain any string deemed safe for user props.
|
|
21
22
|
The startsWidth array will contain the start of any accepted user-prop that
|
|
22
23
|
starts with these characters.
|
|
23
24
|
The exactMatch will contain a list of exact prop names that are accepted.
|
|
24
25
|
*/
|
|
26
|
+
|
|
25
27
|
var USER_PROPS_SAFELIST = {
|
|
26
28
|
startsWith: ["data-", "aria-"],
|
|
27
29
|
exactMatch: []
|
|
@@ -107,4 +109,15 @@ export var getSafeUserProps = function (props) {
|
|
|
107
109
|
|
|
108
110
|
return [key, getValue(value, props)];
|
|
109
111
|
}));
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Wraps a component and adds safe user props
|
|
115
|
+
*
|
|
116
|
+
* @param {ReactNode} component: parent component
|
|
117
|
+
* @param {Object} props: props to be filtered
|
|
118
|
+
* @returns {ReactNode} modified component
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
export var withSafeUserProps = function (component, props) {
|
|
122
|
+
return /*#__PURE__*/React.cloneElement(component, getSafeUserProps(props));
|
|
110
123
|
};
|
|
@@ -21,6 +21,8 @@ var CustomPropTypes = _interopRequireWildcard(require("../victory-util/prop-type
|
|
|
21
21
|
|
|
22
22
|
var Helpers = _interopRequireWildcard(require("../victory-util/helpers"));
|
|
23
23
|
|
|
24
|
+
var UserProps = _interopRequireWildcard(require("../victory-util/user-props"));
|
|
25
|
+
|
|
24
26
|
var _clipPath = _interopRequireDefault(require("../victory-primitives/clip-path"));
|
|
25
27
|
|
|
26
28
|
var _circle = _interopRequireDefault(require("../victory-primitives/circle"));
|
|
@@ -113,6 +115,7 @@ var VictoryClipContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
113
115
|
}, {
|
|
114
116
|
key: "renderClippedGroup",
|
|
115
117
|
value: function renderClippedGroup(props, clipId) {
|
|
118
|
+
var userProps = UserProps.getSafeUserProps(props);
|
|
116
119
|
var style = props.style,
|
|
117
120
|
events = props.events,
|
|
118
121
|
transform = props.transform,
|
|
@@ -129,9 +132,8 @@ var VictoryClipContainer = /*#__PURE__*/function (_React$Component) {
|
|
|
129
132
|
clipPath: "url(#".concat(clipId, ")")
|
|
130
133
|
}, events);
|
|
131
134
|
return /*#__PURE__*/_react.default.cloneElement(groupComponent, _objectSpread(_objectSpread({}, groupProps), {}, {
|
|
132
|
-
"aria-label": props["aria-label"],
|
|
133
135
|
tabIndex: tabIndex
|
|
134
|
-
}), [clipComponent].concat(_toConsumableArray(_react.default.Children.toArray(children))));
|
|
136
|
+
}, userProps), [clipComponent].concat(_toConsumableArray(_react.default.Children.toArray(children))));
|
|
135
137
|
}
|
|
136
138
|
}, {
|
|
137
139
|
key: "renderGroup",
|
|
@@ -35,6 +35,8 @@ var Style = _interopRequireWildcard(require("../victory-util/style"));
|
|
|
35
35
|
|
|
36
36
|
var TextSize = _interopRequireWildcard(require("../victory-util/textsize"));
|
|
37
37
|
|
|
38
|
+
var UserProps = _interopRequireWildcard(require("../victory-util/user-props"));
|
|
39
|
+
|
|
38
40
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
41
|
|
|
40
42
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -495,6 +497,7 @@ var renderLabel = function (calculatedProps, tspanValues) {
|
|
|
495
497
|
tabIndex = calculatedProps.tabIndex,
|
|
496
498
|
tspanComponent = calculatedProps.tspanComponent,
|
|
497
499
|
textComponent = calculatedProps.textComponent;
|
|
500
|
+
var userProps = UserProps.getSafeUserProps(calculatedProps);
|
|
498
501
|
|
|
499
502
|
var textProps = _objectSpread(_objectSpread({
|
|
500
503
|
"aria-label": ariaLabel,
|
|
@@ -510,7 +513,7 @@ var renderLabel = function (calculatedProps, tspanValues) {
|
|
|
510
513
|
desc: Helpers.evaluateProp(desc, calculatedProps),
|
|
511
514
|
tabIndex: Helpers.evaluateProp(tabIndex, calculatedProps),
|
|
512
515
|
id: id
|
|
513
|
-
});
|
|
516
|
+
}, userProps);
|
|
514
517
|
|
|
515
518
|
var tspans = text.map(function (line, i) {
|
|
516
519
|
var currentStyle = tspanValues[i].style;
|
|
@@ -31,8 +31,6 @@ var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
|
31
31
|
|
|
32
32
|
var _victoryTransition = _interopRequireDefault(require("../victory-transition/victory-transition"));
|
|
33
33
|
|
|
34
|
-
var UserProps = _interopRequireWildcard(require("../victory-util/user-props"));
|
|
35
|
-
|
|
36
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
37
35
|
|
|
38
36
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -399,7 +397,6 @@ var _default = function _default(WrappedComponent, options) {
|
|
|
399
397
|
var dataComponent = props.dataComponent,
|
|
400
398
|
labelComponent = props.labelComponent,
|
|
401
399
|
groupComponent = props.groupComponent;
|
|
402
|
-
var userProps = UserProps.getSafeUserProps(props);
|
|
403
400
|
var dataComponents = this.dataKeys.reduce(function (validDataComponents, _dataKey, index) {
|
|
404
401
|
var dataProps = _this9.getComponentProps(dataComponent, "data", index);
|
|
405
402
|
|
|
@@ -419,10 +416,7 @@ var _default = function _default(WrappedComponent, options) {
|
|
|
419
416
|
return undefined;
|
|
420
417
|
}).filter(Boolean);
|
|
421
418
|
var children = [].concat(_toConsumableArray(dataComponents), _toConsumableArray(labelComponents));
|
|
422
|
-
|
|
423
|
-
var group = /*#__PURE__*/_react.default.cloneElement(groupComponent, userProps, children);
|
|
424
|
-
|
|
425
|
-
return this.renderContainer(group, children);
|
|
419
|
+
return this.renderContainer(groupComponent, children);
|
|
426
420
|
}
|
|
427
421
|
}]);
|
|
428
422
|
|
|
@@ -64,10 +64,10 @@ var baseProps = {
|
|
|
64
64
|
eventHandlers: _propTypes.default.object
|
|
65
65
|
})),
|
|
66
66
|
externalEventMutations: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
67
|
-
callback: _propTypes.default.
|
|
67
|
+
callback: _propTypes.default.func,
|
|
68
68
|
childName: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.array]),
|
|
69
69
|
eventKey: _propTypes.default.oneOfType([_propTypes.default.array, CustomPropTypes.allOfType([CustomPropTypes.integer, CustomPropTypes.nonNegative]), _propTypes.default.string]),
|
|
70
|
-
mutation: _propTypes.default.
|
|
70
|
+
mutation: _propTypes.default.func,
|
|
71
71
|
target: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.array])
|
|
72
72
|
})),
|
|
73
73
|
groupComponent: _propTypes.default.element,
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getSafeUserProps = void 0;
|
|
6
|
+
exports.withSafeUserProps = exports.getSafeUserProps = void 0;
|
|
7
|
+
|
|
8
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
|
+
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
7
13
|
|
|
8
14
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
15
|
|
|
@@ -115,5 +121,19 @@ var getSafeUserProps = function (props) {
|
|
|
115
121
|
return [key, getValue(value, props)];
|
|
116
122
|
}));
|
|
117
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* Wraps a component and adds safe user props
|
|
126
|
+
*
|
|
127
|
+
* @param {ReactNode} component: parent component
|
|
128
|
+
* @param {Object} props: props to be filtered
|
|
129
|
+
* @returns {ReactNode} modified component
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
exports.getSafeUserProps = getSafeUserProps;
|
|
134
|
+
|
|
135
|
+
var withSafeUserProps = function (component, props) {
|
|
136
|
+
return /*#__PURE__*/React.cloneElement(component, getSafeUserProps(props));
|
|
137
|
+
};
|
|
118
138
|
|
|
119
|
-
exports.
|
|
139
|
+
exports.withSafeUserProps = withSafeUserProps;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "victory-core",
|
|
3
|
-
"version": "36.4.
|
|
3
|
+
"version": "36.4.1",
|
|
4
4
|
"description": "Victory Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data visualization",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"lodash": "^4.17.21",
|
|
23
|
-
"prop-types": "^15.
|
|
24
|
-
"react-fast-compare": "^2.0
|
|
23
|
+
"prop-types": "^15.8.1",
|
|
24
|
+
"react-fast-compare": "^3.2.0",
|
|
25
25
|
"victory-vendor": "^36.4.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"version": "yarn run nps build-libs && nps build-dists"
|
|
32
32
|
},
|
|
33
33
|
"sideEffects": false,
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "aa44a22e5a93989773a560f765f83ac151f44c46"
|
|
35
35
|
}
|
|
@@ -2,6 +2,7 @@ import React from "react";
|
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
import * as CustomPropTypes from "../victory-util/prop-types";
|
|
4
4
|
import * as Helpers from "../victory-util/helpers";
|
|
5
|
+
import * as UserProps from "../victory-util/user-props";
|
|
5
6
|
import { assign, defaults, isObject, uniqueId } from "lodash";
|
|
6
7
|
import ClipPath from "../victory-primitives/clip-path";
|
|
7
8
|
import Circle from "../victory-primitives/circle";
|
|
@@ -84,6 +85,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
renderClippedGroup(props, clipId) {
|
|
88
|
+
const userProps = UserProps.getSafeUserProps(props);
|
|
87
89
|
const {
|
|
88
90
|
style,
|
|
89
91
|
events,
|
|
@@ -106,7 +108,7 @@ export default class VictoryClipContainer extends React.Component {
|
|
|
106
108
|
);
|
|
107
109
|
return React.cloneElement(
|
|
108
110
|
groupComponent,
|
|
109
|
-
{ ...groupProps,
|
|
111
|
+
{ ...groupProps, tabIndex, ...userProps },
|
|
110
112
|
[clipComponent, ...React.Children.toArray(children)]
|
|
111
113
|
);
|
|
112
114
|
}
|
|
@@ -12,6 +12,7 @@ import * as Log from "../victory-util/log";
|
|
|
12
12
|
import * as CustomPropTypes from "../victory-util/prop-types";
|
|
13
13
|
import * as Style from "../victory-util/style";
|
|
14
14
|
import * as TextSize from "../victory-util/textsize";
|
|
15
|
+
import * as UserProps from "../victory-util/user-props";
|
|
15
16
|
|
|
16
17
|
const defaultStyles = {
|
|
17
18
|
fill: "#252525",
|
|
@@ -487,6 +488,7 @@ const renderLabel = (calculatedProps, tspanValues) => {
|
|
|
487
488
|
tspanComponent,
|
|
488
489
|
textComponent
|
|
489
490
|
} = calculatedProps;
|
|
491
|
+
const userProps = UserProps.getSafeUserProps(calculatedProps);
|
|
490
492
|
|
|
491
493
|
const textProps = {
|
|
492
494
|
"aria-label": ariaLabel,
|
|
@@ -501,7 +503,8 @@ const renderLabel = (calculatedProps, tspanValues) => {
|
|
|
501
503
|
title,
|
|
502
504
|
desc: Helpers.evaluateProp(desc, calculatedProps),
|
|
503
505
|
tabIndex: Helpers.evaluateProp(tabIndex, calculatedProps),
|
|
504
|
-
id
|
|
506
|
+
id,
|
|
507
|
+
...userProps
|
|
505
508
|
};
|
|
506
509
|
|
|
507
510
|
const tspans = text.map((line, i) => {
|
|
@@ -528,6 +531,7 @@ const VictoryLabel = (props) => {
|
|
|
528
531
|
return null;
|
|
529
532
|
}
|
|
530
533
|
const calculatedProps = getCalculatedProps(props);
|
|
534
|
+
|
|
531
535
|
const { text, style, capHeight, backgroundPadding, lineHeight } =
|
|
532
536
|
calculatedProps;
|
|
533
537
|
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
import * as Events from "./events";
|
|
15
15
|
import isEqual from "react-fast-compare";
|
|
16
16
|
import VictoryTransition from "../victory-transition/victory-transition";
|
|
17
|
-
import * as UserProps from "../victory-util/user-props";
|
|
18
17
|
|
|
19
18
|
const datumHasXandY = (datum) => {
|
|
20
19
|
return !isNil(datum._x) && !isNil(datum._y);
|
|
@@ -330,7 +329,6 @@ export default (WrappedComponent, options) => {
|
|
|
330
329
|
|
|
331
330
|
renderData(props, shouldRenderDatum = datumHasXandY) {
|
|
332
331
|
const { dataComponent, labelComponent, groupComponent } = props;
|
|
333
|
-
const userProps = UserProps.getSafeUserProps(props);
|
|
334
332
|
const dataComponents = this.dataKeys.reduce(
|
|
335
333
|
(validDataComponents, _dataKey, index) => {
|
|
336
334
|
const dataProps = this.getComponentProps(
|
|
@@ -363,8 +361,7 @@ export default (WrappedComponent, options) => {
|
|
|
363
361
|
.filter(Boolean);
|
|
364
362
|
|
|
365
363
|
const children = [...dataComponents, ...labelComponents];
|
|
366
|
-
|
|
367
|
-
return this.renderContainer(group, children);
|
|
364
|
+
return this.renderContainer(groupComponent, children);
|
|
368
365
|
}
|
|
369
366
|
};
|
|
370
367
|
};
|
|
@@ -120,7 +120,7 @@ export const baseProps = {
|
|
|
120
120
|
),
|
|
121
121
|
externalEventMutations: PropTypes.arrayOf(
|
|
122
122
|
PropTypes.shape({
|
|
123
|
-
callback: PropTypes.
|
|
123
|
+
callback: PropTypes.func,
|
|
124
124
|
childName: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
125
125
|
eventKey: PropTypes.oneOfType([
|
|
126
126
|
PropTypes.array,
|
|
@@ -130,7 +130,7 @@ export const baseProps = {
|
|
|
130
130
|
]),
|
|
131
131
|
PropTypes.string
|
|
132
132
|
]),
|
|
133
|
-
mutation: PropTypes.
|
|
133
|
+
mutation: PropTypes.func,
|
|
134
134
|
target: PropTypes.oneOfType([PropTypes.string, PropTypes.array])
|
|
135
135
|
})
|
|
136
136
|
),
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
USER_PROPS_SAFELIST is to contain any string deemed safe for user props.
|
|
3
5
|
The startsWidth array will contain the start of any accepted user-prop that
|
|
@@ -79,3 +81,14 @@ export const getSafeUserProps = (props) => {
|
|
|
79
81
|
})
|
|
80
82
|
);
|
|
81
83
|
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Wraps a component and adds safe user props
|
|
87
|
+
*
|
|
88
|
+
* @param {ReactNode} component: parent component
|
|
89
|
+
* @param {Object} props: props to be filtered
|
|
90
|
+
* @returns {ReactNode} modified component
|
|
91
|
+
*/
|
|
92
|
+
export const withSafeUserProps = (component, props) => {
|
|
93
|
+
return React.cloneElement(component, getSafeUserProps(props));
|
|
94
|
+
};
|