Socket
Socket
Sign inDemoInstall

recharts

Package Overview
Dependencies
40
Maintainers
3
Versions
240
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.1 to 2.1.2

12

CHANGELOG.md

@@ -0,1 +1,13 @@

## 2.1.2 (aug 24, 2021)
### fix
- Fixes undefined field reference when optional variables not supplied (#2630)
- Fix fragment children (#2481)
## 2.1.1 (aug 21, 2021)
### fix
- Fix: responsive container
## 2.1.0 (aug 10, 2021)

@@ -2,0 +14,0 @@

1

es6/cartesian/ReferenceArea.js

@@ -32,2 +32,3 @@ import _isFunction from "lodash/isFunction";

yAxis = props.yAxis;
if (!xAxis || !yAxis) return null;
var scales = createLabeledScales({

@@ -34,0 +35,0 @@ x: xAxis.scale,

3

es6/chart/Treemap.js

@@ -567,4 +567,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

width = _this$props9.width,
height = _this$props9.height,
dataKey = _this$props9.dataKey;
height = _this$props9.height;
var _this$state = this.state,

@@ -571,0 +570,0 @@ isTooltipActive = _this$state.isTooltipActive,

/**
* @fileOverview Cross
*/
export var Cell = function Cell(props) {
export var Cell = function Cell(_props) {
return null;
};
Cell.displayName = 'Cell';

@@ -1,5 +0,4 @@

import _flatten from "lodash/flatten";
import _isNil from "lodash/isNil";
import _isString from "lodash/isString";
import _get from "lodash/get";
import _isNil from "lodash/isNil";
import _isArray from "lodash/isArray";

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

import React, { Children } from 'react';
import { Children } from 'react';
import { isFragment } from 'react-is';

@@ -49,2 +48,25 @@ import { isNumber } from './DataUtils';

return Comp.displayName || Comp.name || 'Component';
}; // `toArray` gets called multiple times during the render
// so we can memoize last invocation (since reference to `children` is the same)
var lastChildren = null;
var lastResult = null;
export var toArray = function toArray(children) {
if (children === lastChildren && _isArray(lastResult)) {
return lastResult;
}
var result = [];
Children.forEach(children, function (child) {
if (_isNil(child)) return;
if (isFragment(child)) {
result = result.concat(toArray(child.props.children));
} else {
result.push(child);
}
});
lastResult = result;
lastChildren = children;
return result;
};

@@ -68,7 +90,3 @@ /*

React.Children.forEach(children, function (child) {
if (isFragment(child)) {
result = result.concat(findAllByType(child.props.children, type));
}
toArray(children).forEach(function (child) {
var childType = _get(child, 'type.displayName') || _get(child, 'type.name');

@@ -107,3 +125,3 @@

React.Children.forEach(children, function (child) {
toArray(children).forEach(function (child) {
var displayName = _get(child, 'type.displayName');

@@ -154,3 +172,3 @@

var svgElements = [];
React.Children.forEach(children, function (entry) {
toArray(children).forEach(function (entry) {
if (isSvgElement(entry)) {

@@ -174,8 +192,8 @@ svgElements.push(entry);

if (Children.count(nextChildren) !== Children.count(prevChildren)) {
var count = Children.count(nextChildren);
if (count !== Children.count(prevChildren)) {
return false;
}
var count = Children.count(nextChildren);
if (count === 0) {

@@ -237,3 +255,3 @@ return true;

var record = {};
Children.forEach(children, function (child, index) {
toArray(children).forEach(function (child, index) {
if (isSvgElement(child)) {

@@ -255,5 +273,3 @@ elements.push(child);

});
return _flatten(elements).filter(function (element) {
return !_isNil(element);
});
return elements;
};

@@ -270,9 +286,3 @@ export var getReactEventByType = function getReactEventByType(e) {

export var parseChildIndex = function parseChildIndex(child, children) {
var result = -1;
Children.forEach(children, function (entry, index) {
if (entry === child) {
result = index;
}
});
return result;
return toArray(children).indexOf(child);
};

@@ -47,2 +47,3 @@ "use strict";

yAxis = props.yAxis;
if (!xAxis || !yAxis) return null;
var scales = (0, _CartesianUtils.createLabeledScales)({

@@ -49,0 +50,0 @@ x: xAxis.scale,

@@ -594,4 +594,3 @@ "use strict";

width = _this$props9.width,
height = _this$props9.height,
dataKey = _this$props9.dataKey;
height = _this$props9.height;
var _this$state = this.state,

@@ -598,0 +597,0 @@ isTooltipActive = _this$state.isTooltipActive,

@@ -11,3 +11,3 @@ "use strict";

*/
var Cell = function Cell(props) {
var Cell = function Cell(_props) {
return null;

@@ -14,0 +14,0 @@ };

"use strict";
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.parseChildIndex = exports.getReactEventByType = exports.renderByOrder = exports.isSingleChildEqual = exports.isChildrenEqual = exports.filterSvgElements = exports.validateWidthHeight = exports.withoutType = exports.findChildByType = exports.findAllByType = exports.getDisplayName = exports.TOOLTIP_TYPES = exports.LEGEND_TYPES = exports.SCALE_TYPES = void 0;
exports.parseChildIndex = exports.getReactEventByType = exports.renderByOrder = exports.isSingleChildEqual = exports.isChildrenEqual = exports.filterSvgElements = exports.validateWidthHeight = exports.withoutType = exports.findChildByType = exports.findAllByType = exports.toArray = exports.getDisplayName = exports.TOOLTIP_TYPES = exports.LEGEND_TYPES = exports.SCALE_TYPES = void 0;
var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
var _isString2 = _interopRequireDefault(require("lodash/isString"));

@@ -18,5 +12,7 @@

var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
var _react = _interopRequireWildcard(require("react"));
var _react = require("react");

@@ -29,6 +25,2 @@ var _reactIs = require("react-is");

function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

@@ -77,2 +69,30 @@

return Comp.displayName || Comp.name || 'Component';
}; // `toArray` gets called multiple times during the render
// so we can memoize last invocation (since reference to `children` is the same)
exports.getDisplayName = getDisplayName;
var lastChildren = null;
var lastResult = null;
var toArray = function toArray(children) {
if (children === lastChildren && (0, _isArray2["default"])(lastResult)) {
return lastResult;
}
var result = [];
_react.Children.forEach(children, function (child) {
if ((0, _isNil2["default"])(child)) return;
if ((0, _reactIs.isFragment)(child)) {
result = result.concat(toArray(child.props.children));
} else {
result.push(child);
}
});
lastResult = result;
lastChildren = children;
return result;
};

@@ -85,3 +105,3 @@ /*

exports.getDisplayName = getDisplayName;
exports.toArray = toArray;

@@ -100,7 +120,3 @@ var findAllByType = function findAllByType(children, type) {

_react["default"].Children.forEach(children, function (child) {
if ((0, _reactIs.isFragment)(child)) {
result = result.concat(findAllByType(child.props.children, type));
}
toArray(children).forEach(function (child) {
var childType = (0, _get2["default"])(child, 'type.displayName') || (0, _get2["default"])(child, 'type.name');

@@ -112,3 +128,2 @@

});
return result;

@@ -147,3 +162,3 @@ };

_react["default"].Children.forEach(children, function (child) {
toArray(children).forEach(function (child) {
var displayName = (0, _get2["default"])(child, 'type.displayName');

@@ -157,3 +172,2 @@

});
return newChildren;

@@ -201,4 +215,3 @@ };

var svgElements = [];
_react["default"].Children.forEach(children, function (entry) {
toArray(children).forEach(function (entry) {
if (isSvgElement(entry)) {

@@ -208,3 +221,2 @@ svgElements.push(entry);

});
return svgElements;

@@ -227,8 +239,8 @@ };

if (_react.Children.count(nextChildren) !== _react.Children.count(prevChildren)) {
var count = _react.Children.count(nextChildren);
if (count !== _react.Children.count(prevChildren)) {
return false;
}
var count = _react.Children.count(nextChildren);
if (count === 0) {

@@ -296,4 +308,3 @@ return true;

var record = {};
_react.Children.forEach(children, function (child, index) {
toArray(children).forEach(function (child, index) {
if (isSvgElement(child)) {

@@ -315,6 +326,3 @@ elements.push(child);

});
return (0, _flatten2["default"])(elements).filter(function (element) {
return !(0, _isNil2["default"])(element);
});
return elements;
};

@@ -337,13 +345,5 @@

var parseChildIndex = function parseChildIndex(child, children) {
var result = -1;
_react.Children.forEach(children, function (entry, index) {
if (entry === child) {
result = index;
}
});
return result;
return toArray(children).indexOf(child);
};
exports.parseChildIndex = parseChildIndex;
{
"name": "recharts",
"version": "2.1.1",
"version": "2.1.2",
"description": "React charts",

@@ -5,0 +5,0 @@ "main": "lib/index",

@@ -72,2 +72,25 @@ import React, { Children, ReactNode } from 'react';

// `toArray` gets called multiple times during the render
// so we can memoize last invocation (since reference to `children` is the same)
let lastChildren: ReactNode | null = null;
let lastResult: ReactNode[] | null = null;
export const toArray = <T extends ReactNode>(children: T | T[]): T[] => {
if (children === lastChildren && _.isArray(lastResult)) {
return lastResult as T[];
}
let result: T[] = [];
Children.forEach(children, child => {
if (_.isNil(child)) return;
if (isFragment(child)) {
result = result.concat(toArray(child.props.children));
} else {
result.push(child);
}
});
lastResult = result;
lastChildren = children;
return result;
};
/*

@@ -81,3 +104,3 @@ * Find and return all matched children by type. `type` can be a React element class or

): React.DetailedReactHTMLElement<any, HTMLElement>[] => {
let result: React.DetailedReactHTMLElement<any, HTMLElement>[] = [];
const result: React.DetailedReactHTMLElement<any, HTMLElement>[] = [];
let types: string[] = [];

@@ -91,6 +114,3 @@

React.Children.forEach(children, (child: React.DetailedReactHTMLElement<any, HTMLElement>) => {
if (isFragment(child)) {
result = result.concat(findAllByType(child.props.children, type));
}
toArray(children).forEach((child: React.DetailedReactHTMLElement<any, HTMLElement>) => {
const childType = _.get(child, 'type.displayName') || _.get(child, 'type.name');

@@ -130,3 +150,3 @@ if (types.indexOf(childType) !== -1) {

React.Children.forEach(children, child => {
toArray(children).forEach(child => {
const displayName = _.get(child, 'type.displayName');

@@ -253,3 +273,3 @@

React.Children.forEach(children, (entry: React.ReactElement) => {
toArray(children).forEach((entry: React.ReactElement) => {
if (isSvgElement(entry)) {

@@ -274,6 +294,6 @@ svgElements.push(entry);

if (Children.count(nextChildren) !== Children.count(prevChildren)) {
const count = Children.count(nextChildren);
if (count !== Children.count(prevChildren)) {
return false;
}
const count = Children.count(nextChildren);

@@ -332,5 +352,5 @@ if (count === 0) {

const elements: React.ReactElement[] = [];
const record: any = {};
const record: Record<string, boolean> = {};
Children.forEach(children, (child, index) => {
toArray(children).forEach((child, index) => {
if (isSvgElement(child)) {

@@ -351,3 +371,3 @@ elements.push(child);

return _.flatten(elements).filter(element => !_.isNil(element));
return elements;
};

@@ -366,10 +386,3 @@

export const parseChildIndex = (child: any, children: any[]) => {
let result = -1;
Children.forEach(children, (entry, index) => {
if (entry === child) {
result = index;
}
});
return result;
return toArray(children).indexOf(child);
};

@@ -6,2 +6,3 @@ import React, { ReactNode } from 'react';

export declare const getDisplayName: (Comp: any) => any;
export declare const toArray: <T extends React.ReactNode>(children: T | T[]) => T[];
export declare const findAllByType: (children: ReactNode, type: string | string[]) => React.DetailedReactHTMLElement<any, HTMLElement>[];

@@ -8,0 +9,0 @@ export declare const findChildByType: (children: ReactNode[], type: string) => React.DetailedReactHTMLElement<any, HTMLElement>;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc