victory-voronoi
Advanced tools
Comparing version 32.3.7 to 33.0.0
@@ -1,4 +0,1 @@ | ||
import _uniqueId from "lodash/uniqueId"; | ||
import _isObject from "lodash/isObject"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } | ||
@@ -8,14 +5,2 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
/*eslint no-magic-numbers: ["error", { "ignore": [2] }]*/ | ||
@@ -26,111 +11,68 @@ import React from "react"; | ||
var Voronoi = | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(Voronoi, _React$Component); | ||
var getVoronoiPath = function (props) { | ||
var polygon = props.polygon; | ||
return Array.isArray(polygon) && polygon.length ? "M ".concat(props.polygon.join("L"), " Z") : ""; | ||
}; | ||
function Voronoi(props) { | ||
var _this; | ||
var Voronoi = function (props) { | ||
var role = props.role, | ||
shapeRendering = props.shapeRendering, | ||
className = props.className, | ||
events = props.events, | ||
transform = props.transform; | ||
var voronoiPath = getVoronoiPath(props); | ||
var style = Helpers.evaluateStyle(props.style, props); | ||
var size = Helpers.evaluateProp(props.size, props); | ||
_classCallCheck(this, Voronoi); | ||
var sharedProps = _objectSpread({ | ||
className: className, | ||
role: role, | ||
shapeRendering: shapeRendering, | ||
style: style, | ||
transform: transform | ||
}, events); | ||
_this = _possibleConstructorReturn(this, (Voronoi.__proto__ || Object.getPrototypeOf(Voronoi)).call(this, props)); | ||
_this.clipId = !_isObject(props) || props.clipId === undefined ? _uniqueId("voronoi-clip-") : props.clipId; | ||
return _this; | ||
if (size) { | ||
var circle = React.cloneElement(props.circleComponent, _objectSpread({}, sharedProps, { | ||
key: "".concat(props.id, "-circle-clip"), | ||
clipPath: "url(#".concat(props.clipId, ")"), | ||
cx: props.x, | ||
cy: props.y, | ||
r: size | ||
})); | ||
var voronoiClipPath = React.cloneElement(props.clipPathComponent, { | ||
key: "".concat(props.id, "-voronoi-clip"), | ||
clipId: props.clipId | ||
}, React.cloneElement(props.pathComponent, { | ||
d: voronoiPath, | ||
className: className | ||
})); | ||
return React.cloneElement(props.groupComponent, {}, [voronoiClipPath, circle]); | ||
} | ||
_createClass(Voronoi, [{ | ||
key: "getVoronoiPath", | ||
value: function getVoronoiPath(props) { | ||
var polygon = props.polygon; | ||
return Array.isArray(polygon) && polygon.length ? "M ".concat(props.polygon.join("L"), " Z") : ""; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
datum = _props.datum, | ||
active = _props.active, | ||
role = _props.role, | ||
shapeRendering = _props.shapeRendering, | ||
className = _props.className, | ||
events = _props.events, | ||
x = _props.x, | ||
y = _props.y, | ||
transform = _props.transform, | ||
pathComponent = _props.pathComponent, | ||
clipPathComponent = _props.clipPathComponent, | ||
groupComponent = _props.groupComponent, | ||
circleComponent = _props.circleComponent, | ||
id = _props.id; | ||
var voronoiPath = this.getVoronoiPath(this.props); | ||
var style = Helpers.evaluateStyle(this.props.style, datum, active); | ||
var size = Helpers.evaluateProp(this.props.size, datum, active); | ||
return React.cloneElement(props.pathComponent, _objectSpread({}, sharedProps, { | ||
d: voronoiPath | ||
})); | ||
}; | ||
if (size) { | ||
var circle = React.cloneElement(circleComponent, { | ||
key: "".concat(id, "-circle-clip"), | ||
style: style, | ||
className: className, | ||
role: role, | ||
shapeRendering: shapeRendering, | ||
events: events, | ||
clipPath: "url(#".concat(this.clipId, ")"), | ||
cx: x, | ||
cy: y, | ||
r: size | ||
}); | ||
var voronoiClipPath = React.cloneElement(clipPathComponent, { | ||
key: "".concat(id, "-voronoi-clip"), | ||
clipId: this.clipId | ||
}, React.cloneElement(pathComponent, { | ||
d: voronoiPath, | ||
className: className | ||
})); | ||
return React.cloneElement(groupComponent, {}, [voronoiClipPath, circle]); | ||
} | ||
return React.cloneElement(pathComponent, { | ||
style: style, | ||
className: className, | ||
d: voronoiPath, | ||
role: role, | ||
shapeRendering: shapeRendering, | ||
events: events, | ||
transform: transform | ||
}); | ||
} | ||
}]); | ||
return Voronoi; | ||
}(React.Component); | ||
Object.defineProperty(Voronoi, "propTypes", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: _objectSpread({}, CommonProps.primitiveProps, { | ||
circleComponent: PropTypes.element, | ||
clipId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
clipPathComponent: PropTypes.element, | ||
datum: PropTypes.object, | ||
groupComponent: PropTypes.element, | ||
pathComponent: PropTypes.element, | ||
polygon: PropTypes.array, | ||
size: PropTypes.number, | ||
x: PropTypes.number, | ||
y: PropTypes.number | ||
}) | ||
Voronoi.propTypes = _objectSpread({}, CommonProps.primitiveProps, { | ||
circleComponent: PropTypes.element, | ||
clipId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
clipPathComponent: PropTypes.element, | ||
datum: PropTypes.object, | ||
groupComponent: PropTypes.element, | ||
pathComponent: PropTypes.element, | ||
polygon: PropTypes.array, | ||
size: PropTypes.number, | ||
x: PropTypes.number, | ||
y: PropTypes.number | ||
}); | ||
Object.defineProperty(Voronoi, "defaultProps", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: { | ||
pathComponent: React.createElement(Path, null), | ||
circleComponent: React.createElement(Circle, null), | ||
clipPathComponent: React.createElement(ClipPath, null), | ||
groupComponent: React.createElement("g", null) | ||
} | ||
}); | ||
export { Voronoi as default }; | ||
Voronoi.defaultProps = { | ||
pathComponent: React.createElement(Path, null), | ||
circleComponent: React.createElement(Circle, null), | ||
clipPathComponent: React.createElement(ClipPath, null), | ||
groupComponent: React.createElement("g", null), | ||
role: "presentation", | ||
shapeRendering: "auto" | ||
}; | ||
export default Voronoi; |
@@ -8,6 +8,2 @@ "use strict"; | ||
var _uniqueId2 = _interopRequireDefault(require("lodash/uniqueId")); | ||
var _isObject2 = _interopRequireDefault(require("lodash/isObject")); | ||
var _react = _interopRequireDefault(require("react")); | ||
@@ -25,127 +21,73 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var getVoronoiPath = function (props) { | ||
var polygon = props.polygon; | ||
return Array.isArray(polygon) && polygon.length ? "M ".concat(props.polygon.join("L"), " Z") : ""; | ||
}; | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
var Voronoi = function (props) { | ||
var role = props.role, | ||
shapeRendering = props.shapeRendering, | ||
className = props.className, | ||
events = props.events, | ||
transform = props.transform; | ||
var voronoiPath = getVoronoiPath(props); | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
var style = _victoryCore.Helpers.evaluateStyle(props.style, props); | ||
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
var size = _victoryCore.Helpers.evaluateProp(props.size, props); | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
var sharedProps = _objectSpread({ | ||
className: className, | ||
role: role, | ||
shapeRendering: shapeRendering, | ||
style: style, | ||
transform: transform | ||
}, events); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
if (size) { | ||
var circle = _react.default.cloneElement(props.circleComponent, _objectSpread({}, sharedProps, { | ||
key: "".concat(props.id, "-circle-clip"), | ||
clipPath: "url(#".concat(props.clipId, ")"), | ||
cx: props.x, | ||
cy: props.y, | ||
r: size | ||
})); | ||
var Voronoi = | ||
/*#__PURE__*/ | ||
function (_React$Component) { | ||
_inherits(Voronoi, _React$Component); | ||
var voronoiClipPath = _react.default.cloneElement(props.clipPathComponent, { | ||
key: "".concat(props.id, "-voronoi-clip"), | ||
clipId: props.clipId | ||
}, _react.default.cloneElement(props.pathComponent, { | ||
d: voronoiPath, | ||
className: className | ||
})); | ||
function Voronoi(props) { | ||
var _this; | ||
_classCallCheck(this, Voronoi); | ||
_this = _possibleConstructorReturn(this, (Voronoi.__proto__ || Object.getPrototypeOf(Voronoi)).call(this, props)); | ||
_this.clipId = !(0, _isObject2.default)(props) || props.clipId === undefined ? (0, _uniqueId2.default)("voronoi-clip-") : props.clipId; | ||
return _this; | ||
return _react.default.cloneElement(props.groupComponent, {}, [voronoiClipPath, circle]); | ||
} | ||
_createClass(Voronoi, [{ | ||
key: "getVoronoiPath", | ||
value: function getVoronoiPath(props) { | ||
var polygon = props.polygon; | ||
return Array.isArray(polygon) && polygon.length ? "M ".concat(props.polygon.join("L"), " Z") : ""; | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var _props = this.props, | ||
datum = _props.datum, | ||
active = _props.active, | ||
role = _props.role, | ||
shapeRendering = _props.shapeRendering, | ||
className = _props.className, | ||
events = _props.events, | ||
x = _props.x, | ||
y = _props.y, | ||
transform = _props.transform, | ||
pathComponent = _props.pathComponent, | ||
clipPathComponent = _props.clipPathComponent, | ||
groupComponent = _props.groupComponent, | ||
circleComponent = _props.circleComponent, | ||
id = _props.id; | ||
var voronoiPath = this.getVoronoiPath(this.props); | ||
return _react.default.cloneElement(props.pathComponent, _objectSpread({}, sharedProps, { | ||
d: voronoiPath | ||
})); | ||
}; | ||
var style = _victoryCore.Helpers.evaluateStyle(this.props.style, datum, active); | ||
var size = _victoryCore.Helpers.evaluateProp(this.props.size, datum, active); | ||
if (size) { | ||
var circle = _react.default.cloneElement(circleComponent, { | ||
key: "".concat(id, "-circle-clip"), | ||
style: style, | ||
className: className, | ||
role: role, | ||
shapeRendering: shapeRendering, | ||
events: events, | ||
clipPath: "url(#".concat(this.clipId, ")"), | ||
cx: x, | ||
cy: y, | ||
r: size | ||
}); | ||
var voronoiClipPath = _react.default.cloneElement(clipPathComponent, { | ||
key: "".concat(id, "-voronoi-clip"), | ||
clipId: this.clipId | ||
}, _react.default.cloneElement(pathComponent, { | ||
d: voronoiPath, | ||
className: className | ||
})); | ||
return _react.default.cloneElement(groupComponent, {}, [voronoiClipPath, circle]); | ||
} | ||
return _react.default.cloneElement(pathComponent, { | ||
style: style, | ||
className: className, | ||
d: voronoiPath, | ||
role: role, | ||
shapeRendering: shapeRendering, | ||
events: events, | ||
transform: transform | ||
}); | ||
} | ||
}]); | ||
return Voronoi; | ||
}(_react.default.Component); | ||
exports.default = Voronoi; | ||
Object.defineProperty(Voronoi, "propTypes", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: _objectSpread({}, _victoryCore.CommonProps.primitiveProps, { | ||
circleComponent: _propTypes.default.element, | ||
clipId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), | ||
clipPathComponent: _propTypes.default.element, | ||
datum: _propTypes.default.object, | ||
groupComponent: _propTypes.default.element, | ||
pathComponent: _propTypes.default.element, | ||
polygon: _propTypes.default.array, | ||
size: _propTypes.default.number, | ||
x: _propTypes.default.number, | ||
y: _propTypes.default.number | ||
}) | ||
Voronoi.propTypes = _objectSpread({}, _victoryCore.CommonProps.primitiveProps, { | ||
circleComponent: _propTypes.default.element, | ||
clipId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]), | ||
clipPathComponent: _propTypes.default.element, | ||
datum: _propTypes.default.object, | ||
groupComponent: _propTypes.default.element, | ||
pathComponent: _propTypes.default.element, | ||
polygon: _propTypes.default.array, | ||
size: _propTypes.default.number, | ||
x: _propTypes.default.number, | ||
y: _propTypes.default.number | ||
}); | ||
Object.defineProperty(Voronoi, "defaultProps", { | ||
configurable: true, | ||
enumerable: true, | ||
writable: true, | ||
value: { | ||
pathComponent: _react.default.createElement(_victoryCore.Path, null), | ||
circleComponent: _react.default.createElement(_victoryCore.Circle, null), | ||
clipPathComponent: _react.default.createElement(_victoryCore.ClipPath, null), | ||
groupComponent: _react.default.createElement("g", null) | ||
} | ||
}); | ||
Voronoi.defaultProps = { | ||
pathComponent: _react.default.createElement(_victoryCore.Path, null), | ||
circleComponent: _react.default.createElement(_victoryCore.Circle, null), | ||
clipPathComponent: _react.default.createElement(_victoryCore.ClipPath, null), | ||
groupComponent: _react.default.createElement("g", null), | ||
role: "presentation", | ||
shapeRendering: "auto" | ||
}; | ||
var _default = Voronoi; | ||
exports.default = _default; |
{ | ||
"name": "victory-voronoi", | ||
"version": "32.3.7", | ||
"version": "33.0.0", | ||
"description": "Voronoi Component for Victory", | ||
@@ -25,3 +25,3 @@ "keywords": [ | ||
"prop-types": "^15.5.8", | ||
"victory-core": "^32.3.7" | ||
"victory-core": "^33.0.0" | ||
}, | ||
@@ -28,0 +28,0 @@ "scripts": { |
/*eslint no-magic-numbers: ["error", { "ignore": [2] }]*/ | ||
import React from "react"; | ||
import PropTypes from "prop-types"; | ||
import { isObject, uniqueId } from "lodash"; | ||
import { Helpers, CommonProps, ClipPath, Path, Circle } from "victory-core"; | ||
export default class Voronoi extends React.Component { | ||
static propTypes = { | ||
...CommonProps.primitiveProps, | ||
circleComponent: PropTypes.element, | ||
clipId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
clipPathComponent: PropTypes.element, | ||
datum: PropTypes.object, | ||
groupComponent: PropTypes.element, | ||
pathComponent: PropTypes.element, | ||
polygon: PropTypes.array, | ||
size: PropTypes.number, | ||
x: PropTypes.number, | ||
y: PropTypes.number | ||
}; | ||
const getVoronoiPath = (props) => { | ||
const { polygon } = props; | ||
return Array.isArray(polygon) && polygon.length ? `M ${props.polygon.join("L")} Z` : ""; | ||
}; | ||
static defaultProps = { | ||
pathComponent: <Path />, | ||
circleComponent: <Circle />, | ||
clipPathComponent: <ClipPath />, | ||
groupComponent: <g /> | ||
}; | ||
const Voronoi = (props) => { | ||
const { role, shapeRendering, className, events, transform } = props; | ||
constructor(props) { | ||
super(props); | ||
this.clipId = | ||
!isObject(props) || props.clipId === undefined ? uniqueId("voronoi-clip-") : props.clipId; | ||
} | ||
const voronoiPath = getVoronoiPath(props); | ||
const style = Helpers.evaluateStyle(props.style, props); | ||
const size = Helpers.evaluateProp(props.size, props); | ||
const sharedProps = { className, role, shapeRendering, style, transform, ...events }; | ||
getVoronoiPath(props) { | ||
const { polygon } = props; | ||
return Array.isArray(polygon) && polygon.length ? `M ${props.polygon.join("L")} Z` : ""; | ||
if (size) { | ||
const circle = React.cloneElement(props.circleComponent, { | ||
...sharedProps, | ||
key: `${props.id}-circle-clip`, | ||
clipPath: `url(#${props.clipId})`, | ||
cx: props.x, | ||
cy: props.y, | ||
r: size | ||
}); | ||
const voronoiClipPath = React.cloneElement( | ||
props.clipPathComponent, | ||
{ key: `${props.id}-voronoi-clip`, clipId: props.clipId }, | ||
React.cloneElement(props.pathComponent, { d: voronoiPath, className }) | ||
); | ||
return React.cloneElement(props.groupComponent, {}, [voronoiClipPath, circle]); | ||
} | ||
render() { | ||
const { | ||
datum, | ||
active, | ||
role, | ||
shapeRendering, | ||
className, | ||
events, | ||
x, | ||
y, | ||
transform, | ||
pathComponent, | ||
clipPathComponent, | ||
groupComponent, | ||
circleComponent, | ||
id | ||
} = this.props; | ||
const voronoiPath = this.getVoronoiPath(this.props); | ||
const style = Helpers.evaluateStyle(this.props.style, datum, active); | ||
const size = Helpers.evaluateProp(this.props.size, datum, active); | ||
return React.cloneElement(props.pathComponent, { ...sharedProps, d: voronoiPath }); | ||
}; | ||
if (size) { | ||
const circle = React.cloneElement(circleComponent, { | ||
key: `${id}-circle-clip`, | ||
style, | ||
className, | ||
role, | ||
shapeRendering, | ||
events, | ||
clipPath: `url(#${this.clipId})`, | ||
cx: x, | ||
cy: y, | ||
r: size | ||
}); | ||
const voronoiClipPath = React.cloneElement( | ||
clipPathComponent, | ||
{ key: `${id}-voronoi-clip`, clipId: this.clipId }, | ||
React.cloneElement(pathComponent, { d: voronoiPath, className }) | ||
); | ||
return React.cloneElement(groupComponent, {}, [voronoiClipPath, circle]); | ||
} | ||
return React.cloneElement(pathComponent, { | ||
style, | ||
className, | ||
d: voronoiPath, | ||
role, | ||
shapeRendering, | ||
events, | ||
transform | ||
}); | ||
} | ||
} | ||
Voronoi.propTypes = { | ||
...CommonProps.primitiveProps, | ||
circleComponent: PropTypes.element, | ||
clipId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), | ||
clipPathComponent: PropTypes.element, | ||
datum: PropTypes.object, | ||
groupComponent: PropTypes.element, | ||
pathComponent: PropTypes.element, | ||
polygon: PropTypes.array, | ||
size: PropTypes.number, | ||
x: PropTypes.number, | ||
y: PropTypes.number | ||
}; | ||
Voronoi.defaultProps = { | ||
pathComponent: <Path />, | ||
circleComponent: <Circle />, | ||
clipPathComponent: <ClipPath />, | ||
groupComponent: <g />, | ||
role: "presentation", | ||
shapeRendering: "auto" | ||
}; | ||
export default Voronoi; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1174199
21996
+ Addedvictory-core@33.1.7(transitive)
- Removedvictory-core@32.3.7(transitive)
Updatedvictory-core@^33.0.0