victory-tooltip 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.
package/lib/flyout.js CHANGED
@@ -4,106 +4,114 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.Flyout = void 0;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _victoryCore = require("victory-core");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
- 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; }
15
-
16
- 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; }
17
-
18
- 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; }
19
-
20
- var getVerticalPath = function (props) {
21
- var pointerWidth = props.pointerWidth,
22
- cornerRadius = props.cornerRadius,
23
- orientation = props.orientation,
24
- width = props.width,
25
- height = props.height,
26
- center = props.center;
27
- var sign = orientation === "bottom" ? 1 : -1;
28
- var x = props.x + (props.dx || 0);
29
- var y = props.y + (props.dy || 0);
30
- var centerX = center.x;
31
- var centerY = center.y;
32
- var pointerEdge = centerY + sign * (height / 2);
33
- var oppositeEdge = centerY - sign * (height / 2);
34
- var rightEdge = centerX + width / 2;
35
- var leftEdge = centerX - width / 2;
36
- var pointerLength = sign * (y - pointerEdge) < 0 ? 0 : props.pointerLength;
37
- var direction = orientation === "bottom" ? "0 0 0" : "0 0 1";
38
- var arc = "".concat(cornerRadius, " ").concat(cornerRadius, " ").concat(direction);
39
- return "M ".concat(centerX - pointerWidth / 2, ", ").concat(pointerEdge, "\n L ").concat(pointerLength ? x : centerX + pointerWidth / 2, ", ").concat(pointerLength ? y : pointerEdge, "\n L ").concat(centerX + pointerWidth / 2, ", ").concat(pointerEdge, "\n L ").concat(rightEdge - cornerRadius, ", ").concat(pointerEdge, "\n A ").concat(arc, " ").concat(rightEdge, ", ").concat(pointerEdge - sign * cornerRadius, "\n L ").concat(rightEdge, ", ").concat(oppositeEdge + sign * cornerRadius, "\n A ").concat(arc, " ").concat(rightEdge - cornerRadius, ", ").concat(oppositeEdge, "\n L ").concat(leftEdge + cornerRadius, ", ").concat(oppositeEdge, "\n A ").concat(arc, " ").concat(leftEdge, ", ").concat(oppositeEdge + sign * cornerRadius, "\n L ").concat(leftEdge, ", ").concat(pointerEdge - sign * cornerRadius, "\n A ").concat(arc, " ").concat(leftEdge + cornerRadius, ", ").concat(pointerEdge, "\n z");
10
+ const getVerticalPath = props => {
11
+ const {
12
+ pointerWidth,
13
+ cornerRadius,
14
+ orientation,
15
+ width,
16
+ height,
17
+ center
18
+ } = props;
19
+ const sign = orientation === "bottom" ? 1 : -1;
20
+ const x = props.x + (props.dx || 0);
21
+ const y = props.y + (props.dy || 0);
22
+ const centerX = center.x;
23
+ const centerY = center.y;
24
+ const pointerEdge = centerY + sign * (height / 2);
25
+ const oppositeEdge = centerY - sign * (height / 2);
26
+ const rightEdge = centerX + width / 2;
27
+ const leftEdge = centerX - width / 2;
28
+ const pointerLength = sign * (y - pointerEdge) < 0 ? 0 : props.pointerLength;
29
+ const direction = orientation === "bottom" ? "0 0 0" : "0 0 1";
30
+ const arc = `${cornerRadius} ${cornerRadius} ${direction}`;
31
+ return `M ${centerX - pointerWidth / 2}, ${pointerEdge}
32
+ L ${pointerLength ? x : centerX + pointerWidth / 2}, ${pointerLength ? y : pointerEdge}
33
+ L ${centerX + pointerWidth / 2}, ${pointerEdge}
34
+ L ${rightEdge - cornerRadius}, ${pointerEdge}
35
+ A ${arc} ${rightEdge}, ${pointerEdge - sign * cornerRadius}
36
+ L ${rightEdge}, ${oppositeEdge + sign * cornerRadius}
37
+ A ${arc} ${rightEdge - cornerRadius}, ${oppositeEdge}
38
+ L ${leftEdge + cornerRadius}, ${oppositeEdge}
39
+ A ${arc} ${leftEdge}, ${oppositeEdge + sign * cornerRadius}
40
+ L ${leftEdge}, ${pointerEdge - sign * cornerRadius}
41
+ A ${arc} ${leftEdge + cornerRadius}, ${pointerEdge}
42
+ z`;
40
43
  };
41
-
42
- var getHorizontalPath = function (props) {
43
- var pointerWidth = props.pointerWidth,
44
- cornerRadius = props.cornerRadius,
45
- orientation = props.orientation,
46
- width = props.width,
47
- height = props.height,
48
- center = props.center;
49
- var sign = orientation === "left" ? 1 : -1;
50
- var x = props.x + (props.dx || 0);
51
- var y = props.y + (props.dy || 0);
52
- var centerX = center.x;
53
- var centerY = center.y;
54
- var pointerEdge = centerX - sign * (width / 2);
55
- var oppositeEdge = centerX + sign * (width / 2);
56
- var bottomEdge = centerY + height / 2;
57
- var topEdge = centerY - height / 2;
58
- var pointerLength = sign * (x - pointerEdge) > 0 ? 0 : props.pointerLength;
59
- var direction = orientation === "left" ? "0 0 0" : "0 0 1";
60
- var arc = "".concat(cornerRadius, " ").concat(cornerRadius, " ").concat(direction);
61
- return "M ".concat(pointerEdge, ", ").concat(centerY - pointerWidth / 2, "\n L ").concat(pointerLength ? x : pointerEdge, ", ").concat(pointerLength ? y : centerY + pointerWidth / 2, "\n L ").concat(pointerEdge, ", ").concat(centerY + pointerWidth / 2, "\n L ").concat(pointerEdge, ", ").concat(bottomEdge - cornerRadius, "\n A ").concat(arc, " ").concat(pointerEdge + sign * cornerRadius, ", ").concat(bottomEdge, "\n L ").concat(oppositeEdge - sign * cornerRadius, ", ").concat(bottomEdge, "\n A ").concat(arc, " ").concat(oppositeEdge, ", ").concat(bottomEdge - cornerRadius, "\n L ").concat(oppositeEdge, ", ").concat(topEdge + cornerRadius, "\n A ").concat(arc, " ").concat(oppositeEdge - sign * cornerRadius, ", ").concat(topEdge, "\n L ").concat(pointerEdge + sign * cornerRadius, ", ").concat(topEdge, "\n A ").concat(arc, " ").concat(pointerEdge, ", ").concat(topEdge + cornerRadius, "\n z");
44
+ const getHorizontalPath = props => {
45
+ const {
46
+ pointerWidth,
47
+ cornerRadius,
48
+ orientation,
49
+ width,
50
+ height,
51
+ center
52
+ } = props;
53
+ const sign = orientation === "left" ? 1 : -1;
54
+ const x = props.x + (props.dx || 0);
55
+ const y = props.y + (props.dy || 0);
56
+ const centerX = center.x;
57
+ const centerY = center.y;
58
+ const pointerEdge = centerX - sign * (width / 2);
59
+ const oppositeEdge = centerX + sign * (width / 2);
60
+ const bottomEdge = centerY + height / 2;
61
+ const topEdge = centerY - height / 2;
62
+ const pointerLength = sign * (x - pointerEdge) > 0 ? 0 : props.pointerLength;
63
+ const direction = orientation === "left" ? "0 0 0" : "0 0 1";
64
+ const arc = `${cornerRadius} ${cornerRadius} ${direction}`;
65
+ return `M ${pointerEdge}, ${centerY - pointerWidth / 2}
66
+ L ${pointerLength ? x : pointerEdge}, ${pointerLength ? y : centerY + pointerWidth / 2}
67
+ L ${pointerEdge}, ${centerY + pointerWidth / 2}
68
+ L ${pointerEdge}, ${bottomEdge - cornerRadius}
69
+ A ${arc} ${pointerEdge + sign * cornerRadius}, ${bottomEdge}
70
+ L ${oppositeEdge - sign * cornerRadius}, ${bottomEdge}
71
+ A ${arc} ${oppositeEdge}, ${bottomEdge - cornerRadius}
72
+ L ${oppositeEdge}, ${topEdge + cornerRadius}
73
+ A ${arc} ${oppositeEdge - sign * cornerRadius}, ${topEdge}
74
+ L ${pointerEdge + sign * cornerRadius}, ${topEdge}
75
+ A ${arc} ${pointerEdge}, ${topEdge + cornerRadius}
76
+ z`;
62
77
  };
63
-
64
- var getFlyoutPath = function (props) {
65
- var orientation = props.orientation || "top";
78
+ const getFlyoutPath = props => {
79
+ const orientation = props.orientation || "top";
66
80
  return orientation === "left" || orientation === "right" ? getHorizontalPath(props) : getVerticalPath(props);
67
81
  };
68
-
69
- var evaluateProps = function (props) {
82
+ const evaluateProps = props => {
70
83
  /**
71
84
  * Potential evaluated props are:
72
85
  * `id`
73
86
  * `style`
74
87
  */
75
- var id = _victoryCore.Helpers.evaluateProp(props.id, props);
76
-
77
- var style = _victoryCore.Helpers.evaluateStyle(props.style, props);
78
-
79
- return _objectSpread(_objectSpread({}, props), {}, {
80
- id: id,
81
- style: style
82
- });
88
+ const id = _victoryCore.Helpers.evaluateProp(props.id, props);
89
+ const style = _victoryCore.Helpers.evaluateStyle(props.style, props);
90
+ return {
91
+ ...props,
92
+ id,
93
+ style
94
+ };
83
95
  };
84
-
85
- var defaultProps = {
96
+ const defaultProps = {
86
97
  pathComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Path, null),
87
98
  role: "presentation",
88
99
  shapeRendering: "auto"
89
100
  };
101
+ const Flyout = initialProps => {
102
+ const props = evaluateProps({
103
+ ...defaultProps,
104
+ ...initialProps
105
+ });
106
+ const userProps = _victoryCore.UserProps.getSafeUserProps(props);
90
107
 
91
- var Flyout = function (initialProps) {
92
- var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
93
-
94
- var userProps = _victoryCore.UserProps.getSafeUserProps(props); // check for required props for this subcomponent
108
+ // check for required props for this subcomponent
95
109
  // they should be passed in from the wrapper
96
-
97
-
98
110
  _victoryCore.UserProps.assert(props.height, "Flyout props[height] is undefined");
99
-
100
111
  _victoryCore.UserProps.assert(props.width, "Flyout props[width] is undefined");
101
-
102
112
  _victoryCore.UserProps.assert(props.x, "Flyout props[x] is undefined");
103
-
104
113
  _victoryCore.UserProps.assert(props.y, "Flyout props[y] is undefined");
105
-
106
- var flyoutPathProps = {
114
+ const flyoutPathProps = {
107
115
  center: props.center || {
108
116
  x: 0,
109
117
  y: 0
@@ -119,7 +127,9 @@ var Flyout = function (initialProps) {
119
127
  x: props.x,
120
128
  y: props.y
121
129
  };
122
- return /*#__PURE__*/_react.default.cloneElement(props.pathComponent, _objectSpread(_objectSpread(_objectSpread({}, props.events), userProps), {}, {
130
+ return /*#__PURE__*/_react.default.cloneElement(props.pathComponent, {
131
+ ...props.events,
132
+ ...userProps,
123
133
  style: props.style,
124
134
  d: getFlyoutPath(flyoutPathProps),
125
135
  className: props.className,
@@ -127,7 +137,6 @@ var Flyout = function (initialProps) {
127
137
  role: props.role,
128
138
  transform: props.transform,
129
139
  clipPath: props.clipPath
130
- }));
140
+ });
131
141
  };
132
-
133
142
  exports.Flyout = Flyout;
package/lib/index.js CHANGED
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _victoryTooltip = require("./victory-tooltip");
8
-
9
7
  Object.keys(_victoryTooltip).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _victoryTooltip[key]) return;
@@ -16,9 +14,7 @@ Object.keys(_victoryTooltip).forEach(function (key) {
16
14
  }
17
15
  });
18
16
  });
19
-
20
17
  var _flyout = require("./flyout");
21
-
22
18
  Object.keys(_flyout).forEach(function (key) {
23
19
  if (key === "default" || key === "__esModule") return;
24
20
  if (key in exports && exports[key] === _flyout[key]) return;