victory-core 36.9.2 → 37.0.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.
Files changed (110) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/victory-core.js +4371 -5749
  3. package/dist/victory-core.min.js +1 -1
  4. package/es/victory-accessible-group/victory-accessible-group.js +9 -15
  5. package/es/victory-animation/util.js +28 -47
  6. package/es/victory-animation/victory-animation.js +51 -67
  7. package/es/victory-clip-container/victory-clip-container.js +153 -229
  8. package/es/victory-container/victory-container.js +157 -216
  9. package/es/victory-label/victory-label.js +246 -323
  10. package/es/victory-portal/portal-context.js +1 -2
  11. package/es/victory-portal/portal.js +30 -76
  12. package/es/victory-portal/victory-portal.js +47 -104
  13. package/es/victory-primitives/arc.js +44 -47
  14. package/es/victory-primitives/background.js +14 -17
  15. package/es/victory-primitives/border.js +20 -24
  16. package/es/victory-primitives/circle.js +13 -27
  17. package/es/victory-primitives/clip-path.js +3 -7
  18. package/es/victory-primitives/line-segment.js +20 -24
  19. package/es/victory-primitives/line.js +13 -27
  20. package/es/victory-primitives/path.js +13 -27
  21. package/es/victory-primitives/point.js +36 -40
  22. package/es/victory-primitives/rect.js +13 -27
  23. package/es/victory-primitives/text.js +15 -28
  24. package/es/victory-primitives/tspan.js +13 -26
  25. package/es/victory-primitives/whisker.js +43 -47
  26. package/es/victory-theme/grayscale.js +22 -22
  27. package/es/victory-theme/material.js +46 -46
  28. package/es/victory-theme/victory-theme.js +3 -3
  29. package/es/victory-transition/victory-transition.js +126 -206
  30. package/es/victory-util/add-events.js +263 -374
  31. package/es/victory-util/axis.js +126 -222
  32. package/es/victory-util/collection.js +13 -41
  33. package/es/victory-util/data.js +159 -214
  34. package/es/victory-util/default-transitions.js +33 -51
  35. package/es/victory-util/domain.js +122 -171
  36. package/es/victory-util/events.js +168 -258
  37. package/es/victory-util/helpers.js +153 -178
  38. package/es/victory-util/hooks/use-animation-state.js +61 -99
  39. package/es/victory-util/hooks/use-previous-props.js +2 -2
  40. package/es/victory-util/immutable.js +6 -8
  41. package/es/victory-util/label-helpers.js +128 -130
  42. package/es/victory-util/line-helpers.js +29 -41
  43. package/es/victory-util/log.js +1 -1
  44. package/es/victory-util/point-path-helpers.js +89 -49
  45. package/es/victory-util/scale.js +24 -42
  46. package/es/victory-util/selection.js +39 -40
  47. package/es/victory-util/style.js +8 -13
  48. package/es/victory-util/textsize.js +80 -154
  49. package/es/victory-util/timer-context.js +2 -2
  50. package/es/victory-util/timer.js +40 -76
  51. package/es/victory-util/transitions.js +110 -150
  52. package/es/victory-util/type-helpers.js +2 -3
  53. package/es/victory-util/user-props.js +24 -49
  54. package/es/victory-util/wrapper.js +184 -247
  55. package/lib/index.js +0 -30
  56. package/lib/victory-accessible-group/victory-accessible-group.js +9 -19
  57. package/lib/victory-animation/util.js +28 -63
  58. package/lib/victory-animation/victory-animation.js +54 -83
  59. package/lib/victory-clip-container/victory-clip-container.js +156 -243
  60. package/lib/victory-container/victory-container.js +160 -232
  61. package/lib/victory-label/victory-label.js +248 -344
  62. package/lib/victory-portal/portal-context.js +1 -6
  63. package/lib/victory-portal/portal.js +31 -81
  64. package/lib/victory-portal/victory-portal.js +50 -116
  65. package/lib/victory-primitives/arc.js +48 -57
  66. package/lib/victory-primitives/background.js +16 -28
  67. package/lib/victory-primitives/border.js +22 -34
  68. package/lib/victory-primitives/circle.js +16 -36
  69. package/lib/victory-primitives/clip-path.js +3 -11
  70. package/lib/victory-primitives/index.js +0 -28
  71. package/lib/victory-primitives/line-segment.js +22 -34
  72. package/lib/victory-primitives/line.js +16 -36
  73. package/lib/victory-primitives/path.js +16 -36
  74. package/lib/victory-primitives/point.js +38 -52
  75. package/lib/victory-primitives/rect.js +16 -36
  76. package/lib/victory-primitives/text.js +15 -33
  77. package/lib/victory-primitives/tspan.js +13 -31
  78. package/lib/victory-primitives/whisker.js +45 -57
  79. package/lib/victory-theme/grayscale.js +23 -24
  80. package/lib/victory-theme/material.js +47 -48
  81. package/lib/victory-theme/victory-theme.js +2 -7
  82. package/lib/victory-transition/victory-transition.js +129 -224
  83. package/lib/victory-util/add-events.js +263 -380
  84. package/lib/victory-util/axis.js +128 -241
  85. package/lib/victory-util/collection.js +13 -50
  86. package/lib/victory-util/data.js +160 -239
  87. package/lib/victory-util/default-transitions.js +33 -54
  88. package/lib/victory-util/domain.js +123 -193
  89. package/lib/victory-util/events.js +167 -274
  90. package/lib/victory-util/helpers.js +156 -207
  91. package/lib/victory-util/hooks/index.js +0 -2
  92. package/lib/victory-util/hooks/use-animation-state.js +63 -113
  93. package/lib/victory-util/hooks/use-previous-props.js +2 -7
  94. package/lib/victory-util/immutable.js +6 -18
  95. package/lib/victory-util/index.js +2 -51
  96. package/lib/victory-util/label-helpers.js +130 -141
  97. package/lib/victory-util/line-helpers.js +31 -49
  98. package/lib/victory-util/log.js +1 -2
  99. package/lib/victory-util/point-path-helpers.js +91 -63
  100. package/lib/victory-util/scale.js +26 -57
  101. package/lib/victory-util/selection.js +41 -49
  102. package/lib/victory-util/style.js +8 -16
  103. package/lib/victory-util/textsize.js +80 -157
  104. package/lib/victory-util/timer-context.js +2 -8
  105. package/lib/victory-util/timer.js +40 -76
  106. package/lib/victory-util/transitions.js +110 -152
  107. package/lib/victory-util/type-helpers.js +2 -9
  108. package/lib/victory-util/user-props.js +25 -59
  109. package/lib/victory-util/wrapper.js +186 -281
  110. package/package.json +2 -2
@@ -1,137 +1,99 @@
1
1
  import _defaults from "lodash/defaults";
2
-
3
- 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; }
4
-
5
- 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; }
6
-
7
- 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; }
8
-
9
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
-
11
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
-
13
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
-
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
-
17
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
18
-
19
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
-
21
2
  import React from "react";
22
3
  import * as Collection from "../collection";
23
4
  import * as Transitions from "../transitions";
24
- var INITIAL_STATE = {
5
+ const INITIAL_STATE = {
25
6
  nodesShouldLoad: false,
26
7
  nodesDoneLoad: false,
27
8
  animating: true
28
9
  };
29
- export var useAnimationState = function () {
30
- var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_STATE;
31
-
32
- var _React$useState = React.useState(initialState),
33
- _React$useState2 = _slicedToArray(_React$useState, 2),
34
- state = _React$useState2[0],
35
- _setState = _React$useState2[1]; // This allows us to use a state object and maintain the same API as this.setState
36
-
37
-
38
- var setState = React.useCallback(function (newState) {
39
- _setState(function (oldState) {
40
- return _objectSpread(_objectSpread({}, oldState), newState);
41
- });
42
- }, [_setState]); // This is a copy of Wrapper.getAnimationProps
43
-
44
- var getAnimationProps = React.useCallback(function (props, child, index) {
45
- if (!(props !== null && props !== void 0 && props.animate)) {
10
+ export const useAnimationState = function (initialState) {
11
+ if (initialState === void 0) {
12
+ initialState = INITIAL_STATE;
13
+ }
14
+ const [state, _setState] = React.useState(initialState);
15
+
16
+ // This allows us to use a state object and maintain the same API as this.setState
17
+ const setState = React.useCallback(newState => {
18
+ _setState(oldState => ({
19
+ ...oldState,
20
+ ...newState
21
+ }));
22
+ }, [_setState]);
23
+
24
+ // This is a copy of Wrapper.getAnimationProps
25
+ const getAnimationProps = React.useCallback((props, child, index) => {
26
+ if (!props?.animate) {
46
27
  return child.props.animate;
47
28
  }
48
-
49
- var getFilteredState = function () {
50
- var childrenTransitions = state && state.childrenTransitions;
29
+ const getFilteredState = () => {
30
+ let childrenTransitions = state && state.childrenTransitions;
51
31
  childrenTransitions = Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[index] : childrenTransitions;
52
32
  return _defaults({
53
- childrenTransitions: childrenTransitions
33
+ childrenTransitions
54
34
  }, state);
55
35
  };
56
-
57
- var getTransitions = props.animate && props.animate.getTransitions;
58
- var filteredState = getFilteredState();
59
- var parentState = props.animate && props.animate.parentState || filteredState;
60
-
36
+ let getTransitions = props.animate && props.animate.getTransitions;
37
+ const filteredState = getFilteredState();
38
+ const parentState = props.animate && props.animate.parentState || filteredState;
61
39
  if (!getTransitions) {
62
- var getTransitionProps = Transitions.getTransitionPropsFactory(props, filteredState, function (newState) {
63
- return setState(newState);
64
- });
65
-
66
- getTransitions = function (childComponent) {
67
- return getTransitionProps(childComponent, index);
68
- };
40
+ const getTransitionProps = Transitions.getTransitionPropsFactory(props, filteredState, newState => setState(newState));
41
+ getTransitions = childComponent => getTransitionProps(childComponent, index);
69
42
  }
70
-
71
43
  return _defaults({
72
- getTransitions: getTransitions,
73
- parentState: parentState
44
+ getTransitions,
45
+ parentState
74
46
  }, props.animate, child.props.animate);
75
- }, [state, setState]); // This is a copy of Wrapper.setAnimationState
47
+ }, [state, setState]);
76
48
 
77
- var setAnimationState = React.useCallback(function (props, nextProps) {
78
- if (!(props !== null && props !== void 0 && props.animate)) {
49
+ // This is a copy of Wrapper.setAnimationState
50
+ const setAnimationState = React.useCallback((props, nextProps) => {
51
+ if (!props?.animate) {
79
52
  return;
80
53
  }
81
-
82
54
  if (props.animate.parentState) {
83
- var nodesWillExit = props.animate.parentState.nodesWillExit;
84
- var oldProps = nodesWillExit ? props : null;
85
-
86
- var newState = _defaults({
87
- oldProps: oldProps,
88
- nextProps: nextProps
55
+ const nodesWillExit = props.animate.parentState.nodesWillExit;
56
+ const oldProps = nodesWillExit ? props : null;
57
+ const newState = _defaults({
58
+ oldProps,
59
+ nextProps
89
60
  }, props.animate.parentState);
90
-
91
61
  setState(newState);
92
62
  } else {
93
- var oldChildren = React.Children.toArray(props.children);
94
- var nextChildren = React.Children.toArray(nextProps.children);
95
-
96
- var isContinuous = function (child) {
97
- var check = function (c) {
98
- return c.type && c.type.continuous;
99
- };
100
-
63
+ const oldChildren = React.Children.toArray(props.children);
64
+ const nextChildren = React.Children.toArray(nextProps.children);
65
+ const isContinuous = child => {
66
+ const check = c => c.type && c.type.continuous;
101
67
  return Array.isArray(child) ? child.some(check) : check(child);
102
68
  };
103
-
104
- var continuous = !props.polar && oldChildren.some(function (child) {
105
- var _child$props;
106
-
107
- return isContinuous(child) || (child === null || child === void 0 ? void 0 : (_child$props = child.props) === null || _child$props === void 0 ? void 0 : _child$props.children) && isContinuous(child.props.children);
69
+ const continuous = !props.polar && oldChildren.some(child => {
70
+ return isContinuous(child) || child?.props?.children && isContinuous(child.props.children);
108
71
  });
109
-
110
- var _Transitions$getIniti = Transitions.getInitialTransitionState(oldChildren, nextChildren),
111
- _nodesWillExit = _Transitions$getIniti.nodesWillExit,
112
- nodesWillEnter = _Transitions$getIniti.nodesWillEnter,
113
- childrenTransitions = _Transitions$getIniti.childrenTransitions,
114
- nodesShouldEnter = _Transitions$getIniti.nodesShouldEnter;
115
-
72
+ const {
73
+ nodesWillExit,
74
+ nodesWillEnter,
75
+ childrenTransitions,
76
+ nodesShouldEnter
77
+ } = Transitions.getInitialTransitionState(oldChildren, nextChildren);
116
78
  setState({
117
- nodesWillExit: _nodesWillExit,
118
- nodesWillEnter: nodesWillEnter,
119
- nodesShouldEnter: nodesShouldEnter,
79
+ nodesWillExit,
80
+ nodesWillEnter,
81
+ nodesShouldEnter,
120
82
  childrenTransitions: Collection.isArrayOfArrays(childrenTransitions) ? childrenTransitions[0] : childrenTransitions,
121
- oldProps: _nodesWillExit ? props : undefined,
122
- nextProps: nextProps,
123
- continuous: continuous
83
+ oldProps: nodesWillExit ? props : undefined,
84
+ nextProps,
85
+ continuous
124
86
  });
125
87
  }
126
88
  }, [setState]);
127
- var getProps = React.useCallback(function (initialProps) {
89
+ const getProps = React.useCallback(initialProps => {
128
90
  return state && state.nodesWillExit ? state.oldProps || initialProps : initialProps;
129
91
  }, [state]);
130
92
  return {
131
- state: state,
132
- setState: setState,
133
- getAnimationProps: getAnimationProps,
134
- setAnimationState: setAnimationState,
135
- getProps: getProps
93
+ state,
94
+ setState,
95
+ getAnimationProps,
96
+ setAnimationState,
97
+ getProps
136
98
  };
137
99
  };
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  export function usePreviousProps(props) {
3
- var ref = React.useRef();
4
- React.useEffect(function () {
3
+ const ref = React.useRef();
4
+ React.useEffect(() => {
5
5
  ref.current = props;
6
6
  });
7
7
  return ref.current;
@@ -1,7 +1,7 @@
1
- export var IMMUTABLE_ITERABLE = "@@__IMMUTABLE_ITERABLE__@@";
2
- export var IMMUTABLE_RECORD = "@@__IMMUTABLE_RECORD__@@";
3
- export var IMMUTABLE_LIST = "@@__IMMUTABLE_LIST__@@";
4
- export var IMMUTABLE_MAP = "@@__IMMUTABLE_MAP__@@";
1
+ export const IMMUTABLE_ITERABLE = "@@__IMMUTABLE_ITERABLE__@@";
2
+ export const IMMUTABLE_RECORD = "@@__IMMUTABLE_RECORD__@@";
3
+ export const IMMUTABLE_LIST = "@@__IMMUTABLE_LIST__@@";
4
+ export const IMMUTABLE_MAP = "@@__IMMUTABLE_MAP__@@";
5
5
  export function isIterable(x) {
6
6
  return !!(x && x[IMMUTABLE_ITERABLE]);
7
7
  }
@@ -18,13 +18,11 @@ export function isMap(x) {
18
18
  return !!(x && x[IMMUTABLE_MAP]);
19
19
  }
20
20
  export function shallowToJS(x, whitelist) {
21
- return isIterable(x) ? x.reduce(function (result, curr, key) {
22
- var newCurr = curr;
23
-
21
+ return isIterable(x) ? x.reduce((result, curr, key) => {
22
+ let newCurr = curr;
24
23
  if (whitelist && whitelist[key]) {
25
24
  newCurr = shallowToJS(curr);
26
25
  }
27
-
28
26
  result[key] = newCurr;
29
27
  return result;
30
28
  }, isList(x) ? [] : {}) : x;
@@ -1,164 +1,164 @@
1
1
  import _defaults from "lodash/defaults";
2
+ /* eslint-disable no-use-before-define */
2
3
  import * as Helpers from "./helpers";
3
-
4
4
  // Private Functions
5
- function getVerticalAnchor(props) {
6
- var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
7
- var sign = datum._y >= 0 ? 1 : -1;
8
- var labelStyle = props.style && props.style.labels || {};
9
5
 
6
+ function getVerticalAnchor(props, datum) {
7
+ if (datum === void 0) {
8
+ datum = {};
9
+ }
10
+ const sign = datum._y >= 0 ? 1 : -1;
11
+ const labelStyle = props.style && props.style.labels || {};
10
12
  if (datum.verticalAnchor || labelStyle.verticalAnchor) {
11
13
  return datum.verticalAnchor || labelStyle.verticalAnchor;
12
14
  } else if (!props.horizontal) {
13
15
  return sign >= 0 ? "end" : "start";
14
16
  }
15
-
16
17
  return "middle";
17
18
  }
18
-
19
- function getTextAnchor(props) {
20
- var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
21
- var style = props.style,
22
- horizontal = props.horizontal;
23
- var sign = datum._y >= 0 ? 1 : -1;
24
- var labelStyle = style && style.labels || {};
25
-
19
+ function getTextAnchor(props, datum) {
20
+ if (datum === void 0) {
21
+ datum = {};
22
+ }
23
+ const {
24
+ style,
25
+ horizontal
26
+ } = props;
27
+ const sign = datum._y >= 0 ? 1 : -1;
28
+ const labelStyle = style && style.labels || {};
26
29
  if (datum.verticalAnchor || labelStyle.verticalAnchor) {
27
30
  return datum.verticalAnchor || labelStyle.verticalAnchor;
28
31
  } else if (!horizontal) {
29
32
  return "middle";
30
33
  }
31
-
32
34
  return sign >= 0 ? "start" : "end";
33
35
  }
34
-
35
- function getAngle(props) {
36
- var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
37
- var labelStyle = props.style && props.style.labels || {};
36
+ function getAngle(props, datum) {
37
+ if (datum === void 0) {
38
+ datum = {};
39
+ }
40
+ const labelStyle = props.style && props.style.labels || {};
38
41
  return datum.angle === undefined ? labelStyle.angle : datum.angle;
39
42
  }
40
-
41
- function getPadding(props) {
42
- var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
43
- var horizontal = props.horizontal,
44
- style = props.style;
45
- var labelStyle = style.labels || {};
46
- var defaultPadding = Helpers.evaluateProp(labelStyle.padding, props) || 0;
47
- var sign = datum._y < 0 ? -1 : 1;
43
+ function getPadding(props, datum) {
44
+ if (datum === void 0) {
45
+ datum = {};
46
+ }
47
+ const {
48
+ horizontal,
49
+ style
50
+ } = props;
51
+ const labelStyle = style.labels || {};
52
+ const defaultPadding = Helpers.evaluateProp(labelStyle.padding, props) || 0;
53
+ const sign = datum._y < 0 ? -1 : 1;
48
54
  return {
49
55
  x: horizontal ? sign * defaultPadding : 0,
50
56
  y: horizontal ? 0 : -1 * sign * defaultPadding
51
57
  };
52
58
  }
53
-
54
59
  function getOffset(props, datum) {
55
60
  if (props.polar) {
56
61
  return {};
57
62
  }
58
-
59
- var padding = getPadding(props, datum);
63
+ const padding = getPadding(props, datum);
60
64
  return {
61
65
  dx: padding.x,
62
66
  dy: padding.y
63
67
  };
64
68
  }
65
-
66
69
  function getPosition(props, datum) {
67
- var polar = props.polar;
68
-
69
- var _Helpers$scalePoint = Helpers.scalePoint(props, datum),
70
- x = _Helpers$scalePoint.x,
71
- y = _Helpers$scalePoint.y;
72
-
70
+ const {
71
+ polar
72
+ } = props;
73
+ const {
74
+ x,
75
+ y
76
+ } = Helpers.scalePoint(props, datum);
73
77
  if (!polar) {
74
78
  return {
75
- x: x,
76
- y: y
79
+ x,
80
+ y
77
81
  };
78
82
  }
79
-
80
- var polarPadding = getPolarPadding(props, datum);
83
+ const polarPadding = getPolarPadding(props, datum);
81
84
  return {
82
85
  x: x + polarPadding.x,
83
86
  y: y + polarPadding.y
84
87
  };
85
88
  }
86
-
87
89
  function getPolarPadding(props, datum) {
88
- var style = props.style;
89
- var degrees = getDegrees(props, datum);
90
- var labelStyle = style.labels || {};
91
- var padding = Helpers.evaluateProp(labelStyle.padding, props) || 0;
92
- var angle = Helpers.degreesToRadians(degrees);
90
+ const {
91
+ style
92
+ } = props;
93
+ const degrees = getDegrees(props, datum);
94
+ const labelStyle = style.labels || {};
95
+ const padding = Helpers.evaluateProp(labelStyle.padding, props) || 0;
96
+ const angle = Helpers.degreesToRadians(degrees);
93
97
  return {
94
98
  x: padding * Math.cos(angle),
95
99
  y: -padding * Math.sin(angle)
96
100
  };
97
101
  }
98
-
99
102
  function getLabelPlacement(props) {
100
- var labelComponent = props.labelComponent,
101
- labelPlacement = props.labelPlacement,
102
- polar = props.polar;
103
- var defaultLabelPlacement = polar ? "perpendicular" : "vertical";
103
+ const {
104
+ labelComponent,
105
+ labelPlacement,
106
+ polar
107
+ } = props;
108
+ const defaultLabelPlacement = polar ? "perpendicular" : "vertical";
104
109
  return labelPlacement ? labelPlacement : labelComponent.props && labelComponent.props.labelPlacement || defaultLabelPlacement;
105
110
  }
106
-
107
111
  function getPolarOrientation(degrees) {
108
112
  // eslint-disable-next-line no-magic-numbers
109
113
  if (degrees < 45 || degrees > 315) {
110
- return "right"; // eslint-disable-next-line no-magic-numbers
114
+ return "right";
115
+ // eslint-disable-next-line no-magic-numbers
111
116
  } else if (degrees >= 45 && degrees <= 135) {
112
- return "top"; // eslint-disable-next-line no-magic-numbers
117
+ return "top";
118
+ // eslint-disable-next-line no-magic-numbers
113
119
  } else if (degrees > 135 && degrees < 225) {
114
120
  return "left";
115
121
  }
116
-
117
122
  return "bottom";
118
- } // Exported Functions
119
-
123
+ }
120
124
 
121
- export function getText(props) {
122
- var datum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
123
- var index = arguments.length > 2 ? arguments[2] : undefined;
125
+ // Exported Functions
124
126
 
127
+ export function getText(props, datum, index) {
128
+ if (datum === void 0) {
129
+ datum = {};
130
+ }
125
131
  if (datum.label !== undefined) {
126
132
  return datum.label;
127
133
  }
128
-
129
134
  return Array.isArray(props.labels) ? props.labels[index] : props.labels;
130
135
  }
131
136
  export function getPolarTextAnchor(props, degrees) {
132
- var labelPlacement = getLabelPlacement(props);
133
-
137
+ const labelPlacement = getLabelPlacement(props);
134
138
  if (labelPlacement === "perpendicular" || labelPlacement === "vertical" && (degrees === 90 || degrees === 270)) {
135
139
  return "middle";
136
140
  }
137
-
138
141
  return degrees <= 90 || degrees > 270 ? "start" : "end";
139
142
  }
140
143
  export function getPolarVerticalAnchor(props, degrees) {
141
- var labelPlacement = getLabelPlacement(props);
142
- var orientation = getPolarOrientation(degrees);
143
-
144
+ const labelPlacement = getLabelPlacement(props);
145
+ const orientation = getPolarOrientation(degrees);
144
146
  if (labelPlacement === "parallel" || orientation === "left" || orientation === "right") {
145
147
  return "middle";
146
148
  }
147
-
148
149
  return orientation === "top" ? "end" : "start";
149
150
  }
150
151
  export function getPolarAngle(props, baseAngle) {
151
- var labelPlacement = props.labelPlacement,
152
- datum = props.datum;
153
-
152
+ const {
153
+ labelPlacement,
154
+ datum
155
+ } = props;
154
156
  if (!labelPlacement || labelPlacement === "vertical") {
155
157
  return 0;
156
158
  }
157
-
158
- var degrees = baseAngle !== undefined ? baseAngle % 360 : getDegrees(props, datum);
159
- var sign = degrees > 90 && degrees < 180 || degrees > 270 ? 1 : -1;
160
- var angle = 0;
161
-
159
+ const degrees = baseAngle !== undefined ? baseAngle % 360 : getDegrees(props, datum);
160
+ const sign = degrees > 90 && degrees < 180 || degrees > 270 ? 1 : -1;
161
+ let angle = 0;
162
162
  if (degrees === 0 || degrees === 180) {
163
163
  angle = 90;
164
164
  } else if (degrees > 0 && degrees < 180) {
@@ -166,69 +166,67 @@ export function getPolarAngle(props, baseAngle) {
166
166
  } else if (degrees > 180 && degrees < 360) {
167
167
  angle = 270 - degrees;
168
168
  }
169
-
170
- var labelRotation = labelPlacement === "perpendicular" ? 0 : 90;
169
+ const labelRotation = labelPlacement === "perpendicular" ? 0 : 90;
171
170
  return angle + sign * labelRotation;
172
171
  }
173
172
  export function getDegrees(props, datum) {
174
- var _Helpers$getPoint = Helpers.getPoint(datum),
175
- x = _Helpers$getPoint.x;
176
-
173
+ const {
174
+ x
175
+ } = Helpers.getPoint(datum);
177
176
  return Helpers.radiansToDegrees(props.scale.x(x)) % 360;
178
177
  }
179
178
  export function getProps(props, index) {
180
- var scale = props.scale,
181
- data = props.data,
182
- style = props.style,
183
- horizontal = props.horizontal,
184
- polar = props.polar,
185
- width = props.width,
186
- height = props.height,
187
- theme = props.theme,
188
- labelComponent = props.labelComponent,
189
- disableInlineStyles = props.disableInlineStyles;
190
- var datum = data[index];
191
- var degrees = getDegrees(props, datum);
192
- var textAnchor = polar ? getPolarTextAnchor(props, degrees) : getTextAnchor(props, datum);
193
- var verticalAnchor = polar ? getPolarVerticalAnchor(props, degrees) : getVerticalAnchor(props, datum);
194
- var angle = getAngle(props, datum);
195
- var text = getText(props, datum, index);
196
- var labelPlacement = getLabelPlacement(props);
197
-
198
- var _getPosition = getPosition(props, datum),
199
- x = _getPosition.x,
200
- y = _getPosition.y;
201
-
202
- var _getOffset = getOffset(props, datum),
203
- dx = _getOffset.dx,
204
- dy = _getOffset.dy;
205
-
206
- var labelProps = {
207
- angle: angle,
208
- data: data,
209
- datum: datum,
210
- disableInlineStyles: disableInlineStyles,
211
- horizontal: horizontal,
212
- index: index,
213
- polar: polar,
214
- scale: scale,
215
- labelPlacement: labelPlacement,
216
- text: text,
217
- textAnchor: textAnchor,
218
- verticalAnchor: verticalAnchor,
219
- x: x,
220
- y: y,
221
- dx: dx,
222
- dy: dy,
223
- width: width,
224
- height: height,
179
+ const {
180
+ scale,
181
+ data,
182
+ style,
183
+ horizontal,
184
+ polar,
185
+ width,
186
+ height,
187
+ theme,
188
+ labelComponent,
189
+ disableInlineStyles
190
+ } = props;
191
+ const datum = data[index];
192
+ const degrees = getDegrees(props, datum);
193
+ const textAnchor = polar ? getPolarTextAnchor(props, degrees) : getTextAnchor(props, datum);
194
+ const verticalAnchor = polar ? getPolarVerticalAnchor(props, degrees) : getVerticalAnchor(props, datum);
195
+ const angle = getAngle(props, datum);
196
+ const text = getText(props, datum, index);
197
+ const labelPlacement = getLabelPlacement(props);
198
+ const {
199
+ x,
200
+ y
201
+ } = getPosition(props, datum);
202
+ const {
203
+ dx,
204
+ dy
205
+ } = getOffset(props, datum);
206
+ const labelProps = {
207
+ angle,
208
+ data,
209
+ datum,
210
+ disableInlineStyles,
211
+ horizontal,
212
+ index,
213
+ polar,
214
+ scale,
215
+ labelPlacement,
216
+ text,
217
+ textAnchor,
218
+ verticalAnchor,
219
+ x,
220
+ y,
221
+ dx,
222
+ dy,
223
+ width,
224
+ height,
225
225
  style: style.labels
226
226
  };
227
-
228
227
  if (!Helpers.isTooltip(labelComponent)) {
229
228
  return labelProps;
230
229
  }
231
-
232
- var tooltipTheme = theme && theme.tooltip || {};
230
+ const tooltipTheme = theme && theme.tooltip || {};
233
231
  return _defaults({}, labelProps, Helpers.omit(tooltipTheme, ["style"]));
234
232
  }