Socket
Socket
Sign inDemoInstall

@visx/shape

Package Overview
Dependencies
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visx/shape - npm Package Compare versions

Comparing version 2.2.2 to 2.4.0

95

esm/shapes/BarRounded.js

@@ -1,2 +0,2 @@

var _excluded = ["className", "innerRef", "x", "y", "width", "height", "radius", "all", "top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight"];
var _excluded = ["children", "className", "innerRef", "x", "y", "width", "height", "radius", "all", "top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight"];

@@ -9,30 +9,19 @@ function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

import cx from 'classnames';
export default function BarRounded(_ref) {
var className = _ref.className,
innerRef = _ref.innerRef,
x = _ref.x,
y = _ref.y,
width = _ref.width,
/** Hook that returns a BarRounded path. */
export function useBarRoundedPath(_ref) {
var all = _ref.all,
bottom = _ref.bottom,
bottomLeft = _ref.bottomLeft,
bottomRight = _ref.bottomRight,
height = _ref.height,
left = _ref.left,
radius = _ref.radius,
_ref$all = _ref.all,
all = _ref$all === void 0 ? false : _ref$all,
_ref$top = _ref.top,
top = _ref$top === void 0 ? false : _ref$top,
_ref$bottom = _ref.bottom,
bottom = _ref$bottom === void 0 ? false : _ref$bottom,
_ref$left = _ref.left,
left = _ref$left === void 0 ? false : _ref$left,
_ref$right = _ref.right,
right = _ref$right === void 0 ? false : _ref$right,
_ref$topLeft = _ref.topLeft,
topLeft = _ref$topLeft === void 0 ? false : _ref$topLeft,
_ref$topRight = _ref.topRight,
topRight = _ref$topRight === void 0 ? false : _ref$topRight,
_ref$bottomLeft = _ref.bottomLeft,
bottomLeft = _ref$bottomLeft === void 0 ? false : _ref$bottomLeft,
_ref$bottomRight = _ref.bottomRight,
bottomRight = _ref$bottomRight === void 0 ? false : _ref$bottomRight,
restProps = _objectWithoutPropertiesLoose(_ref, _excluded);
right = _ref.right,
top = _ref.top,
topLeft = _ref.topLeft,
topRight = _ref.topRight,
width = _ref.width,
x = _ref.x,
y = _ref.y;
topRight = all || top || right || topRight;

@@ -43,5 +32,55 @@ bottomRight = all || bottom || right || bottomRight;

radius = Math.min(radius, Math.min(width, height) / 2);
radius = Math.max(1, Math.min(radius, Math.min(width, height) / 2));
var diameter = 2 * radius;
var path = ("M" + (x + radius) + "," + y + " h" + (width - diameter) + "\n " + (topRight ? "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius : "h" + radius + "v" + radius) + "\n v" + (height - diameter) + "\n " + (bottomRight ? "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + radius : "v" + radius + "h" + -radius) + "\n h" + (diameter - width) + "\n " + (bottomLeft ? "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + -radius : "h" + -radius + "v" + -radius) + "\n v" + (diameter - height) + "\n " + (topLeft ? "a" + radius + "," + radius + " 0 0 1 " + radius + "," + -radius : "v" + -radius + "h" + radius) + "\nz").split('\n').join('');
return path;
}
export default function BarRounded(_ref2) {
var children = _ref2.children,
className = _ref2.className,
innerRef = _ref2.innerRef,
x = _ref2.x,
y = _ref2.y,
width = _ref2.width,
height = _ref2.height,
radius = _ref2.radius,
_ref2$all = _ref2.all,
all = _ref2$all === void 0 ? false : _ref2$all,
_ref2$top = _ref2.top,
top = _ref2$top === void 0 ? false : _ref2$top,
_ref2$bottom = _ref2.bottom,
bottom = _ref2$bottom === void 0 ? false : _ref2$bottom,
_ref2$left = _ref2.left,
left = _ref2$left === void 0 ? false : _ref2$left,
_ref2$right = _ref2.right,
right = _ref2$right === void 0 ? false : _ref2$right,
_ref2$topLeft = _ref2.topLeft,
topLeft = _ref2$topLeft === void 0 ? false : _ref2$topLeft,
_ref2$topRight = _ref2.topRight,
topRight = _ref2$topRight === void 0 ? false : _ref2$topRight,
_ref2$bottomLeft = _ref2.bottomLeft,
bottomLeft = _ref2$bottomLeft === void 0 ? false : _ref2$bottomLeft,
_ref2$bottomRight = _ref2.bottomRight,
bottomRight = _ref2$bottomRight === void 0 ? false : _ref2$bottomRight,
restProps = _objectWithoutPropertiesLoose(_ref2, _excluded);
var path = useBarRoundedPath({
x: x,
y: y,
width: width,
height: height,
radius: radius,
all: all,
top: top,
bottom: bottom,
left: left,
right: right,
topLeft: topLeft,
topRight: topRight,
bottomLeft: bottomLeft,
bottomRight: bottomRight
});
if (children) return /*#__PURE__*/React.createElement(React.Fragment, null, children({
path: path
}));
return /*#__PURE__*/React.createElement("path", _extends({

@@ -48,0 +87,0 @@ ref: innerRef,

@@ -36,4 +36,10 @@ import React from 'react';

bottomRight?: boolean;
/** Optional children override. */
children?: ({ path }: {
path: string;
}) => React.ReactNode;
};
export default function BarRounded({ className, innerRef, x, y, width, height, radius, all, top, bottom, left, right, topLeft, topRight, bottomLeft, bottomRight, ...restProps }: AddSVGProps<BarRoundedProps, SVGPathElement>): JSX.Element;
/** Hook that returns a BarRounded path. */
export declare function useBarRoundedPath({ all, bottom, bottomLeft, bottomRight, height, left, radius, right, top, topLeft, topRight, width, x, y, }: Pick<BarRoundedProps, 'all' | 'top' | 'bottom' | 'left' | 'right' | 'x' | 'y' | 'width' | 'height' | 'radius' | 'topLeft' | 'topRight' | 'bottomRight' | 'bottomLeft'>): string;
export default function BarRounded({ children, className, innerRef, x, y, width, height, radius, all, top, bottom, left, right, topLeft, topRight, bottomLeft, bottomRight, ...restProps }: AddSVGProps<BarRoundedProps, SVGPathElement>): JSX.Element;
//# sourceMappingURL=BarRounded.d.ts.map
"use strict";
exports.__esModule = true;
exports.useBarRoundedPath = useBarRoundedPath;
exports.default = BarRounded;

@@ -10,3 +11,3 @@

var _excluded = ["className", "innerRef", "x", "y", "width", "height", "radius", "all", "top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight"];
var _excluded = ["children", "className", "innerRef", "x", "y", "width", "height", "radius", "all", "top", "bottom", "left", "right", "topLeft", "topRight", "bottomLeft", "bottomRight"];

@@ -19,30 +20,18 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function BarRounded(_ref) {
var className = _ref.className,
innerRef = _ref.innerRef,
x = _ref.x,
y = _ref.y,
width = _ref.width,
/** Hook that returns a BarRounded path. */
function useBarRoundedPath(_ref) {
var all = _ref.all,
bottom = _ref.bottom,
bottomLeft = _ref.bottomLeft,
bottomRight = _ref.bottomRight,
height = _ref.height,
left = _ref.left,
radius = _ref.radius,
_ref$all = _ref.all,
all = _ref$all === void 0 ? false : _ref$all,
_ref$top = _ref.top,
top = _ref$top === void 0 ? false : _ref$top,
_ref$bottom = _ref.bottom,
bottom = _ref$bottom === void 0 ? false : _ref$bottom,
_ref$left = _ref.left,
left = _ref$left === void 0 ? false : _ref$left,
_ref$right = _ref.right,
right = _ref$right === void 0 ? false : _ref$right,
_ref$topLeft = _ref.topLeft,
topLeft = _ref$topLeft === void 0 ? false : _ref$topLeft,
_ref$topRight = _ref.topRight,
topRight = _ref$topRight === void 0 ? false : _ref$topRight,
_ref$bottomLeft = _ref.bottomLeft,
bottomLeft = _ref$bottomLeft === void 0 ? false : _ref$bottomLeft,
_ref$bottomRight = _ref.bottomRight,
bottomRight = _ref$bottomRight === void 0 ? false : _ref$bottomRight,
restProps = _objectWithoutPropertiesLoose(_ref, _excluded);
right = _ref.right,
top = _ref.top,
topLeft = _ref.topLeft,
topRight = _ref.topRight,
width = _ref.width,
x = _ref.x,
y = _ref.y;
topRight = all || top || right || topRight;

@@ -53,5 +42,56 @@ bottomRight = all || bottom || right || bottomRight;

radius = Math.min(radius, Math.min(width, height) / 2);
radius = Math.max(1, Math.min(radius, Math.min(width, height) / 2));
var diameter = 2 * radius;
var path = ("M" + (x + radius) + "," + y + " h" + (width - diameter) + "\n " + (topRight ? "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius : "h" + radius + "v" + radius) + "\n v" + (height - diameter) + "\n " + (bottomRight ? "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + radius : "v" + radius + "h" + -radius) + "\n h" + (diameter - width) + "\n " + (bottomLeft ? "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + -radius : "h" + -radius + "v" + -radius) + "\n v" + (diameter - height) + "\n " + (topLeft ? "a" + radius + "," + radius + " 0 0 1 " + radius + "," + -radius : "v" + -radius + "h" + radius) + "\nz").split('\n').join('');
return path;
}
function BarRounded(_ref2) {
var children = _ref2.children,
className = _ref2.className,
innerRef = _ref2.innerRef,
x = _ref2.x,
y = _ref2.y,
width = _ref2.width,
height = _ref2.height,
radius = _ref2.radius,
_ref2$all = _ref2.all,
all = _ref2$all === void 0 ? false : _ref2$all,
_ref2$top = _ref2.top,
top = _ref2$top === void 0 ? false : _ref2$top,
_ref2$bottom = _ref2.bottom,
bottom = _ref2$bottom === void 0 ? false : _ref2$bottom,
_ref2$left = _ref2.left,
left = _ref2$left === void 0 ? false : _ref2$left,
_ref2$right = _ref2.right,
right = _ref2$right === void 0 ? false : _ref2$right,
_ref2$topLeft = _ref2.topLeft,
topLeft = _ref2$topLeft === void 0 ? false : _ref2$topLeft,
_ref2$topRight = _ref2.topRight,
topRight = _ref2$topRight === void 0 ? false : _ref2$topRight,
_ref2$bottomLeft = _ref2.bottomLeft,
bottomLeft = _ref2$bottomLeft === void 0 ? false : _ref2$bottomLeft,
_ref2$bottomRight = _ref2.bottomRight,
bottomRight = _ref2$bottomRight === void 0 ? false : _ref2$bottomRight,
restProps = _objectWithoutPropertiesLoose(_ref2, _excluded);
var path = useBarRoundedPath({
x: x,
y: y,
width: width,
height: height,
radius: radius,
all: all,
top: top,
bottom: bottom,
left: left,
right: right,
topLeft: topLeft,
topRight: topRight,
bottomLeft: bottomLeft,
bottomRight: bottomRight
});
if (children) return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children({
path: path
}));
return /*#__PURE__*/_react.default.createElement("path", _extends({

@@ -58,0 +98,0 @@ ref: innerRef,

{
"name": "@visx/shape",
"version": "2.2.2",
"version": "2.4.0",
"description": "visx shape",

@@ -47,3 +47,3 @@ "sideEffects": false,

},
"gitHead": "488a0e570b86f00386e24de72705b312d3f10048"
"gitHead": "a445ae7da3025e808e49d2784ae822e356e5db41"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc