| 1 | function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|---|
| 2 | import * as React from 'react';
|
|---|
| 3 | import invariant from 'tiny-invariant';
|
|---|
| 4 | import { Shape } from './ActiveShapeUtils';
|
|---|
| 5 | import { isNullish, isNumber } from './DataUtils';
|
|---|
| 6 | export function BarRectangle(props) {
|
|---|
| 7 | return /*#__PURE__*/React.createElement(Shape, _extends({
|
|---|
| 8 | shapeType: "rectangle",
|
|---|
| 9 | activeClassName: "recharts-active-bar"
|
|---|
| 10 | }, props));
|
|---|
| 11 | }
|
|---|
| 12 | /**
|
|---|
| 13 | * Safely gets minPointSize from the minPointSize prop if it is a function
|
|---|
| 14 | * @param minPointSize minPointSize as passed to the Bar component
|
|---|
| 15 | * @param defaultValue default minPointSize
|
|---|
| 16 | * @returns minPointSize
|
|---|
| 17 | */
|
|---|
| 18 | export var minPointSizeCallback = function minPointSizeCallback(minPointSize) {
|
|---|
| 19 | var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|---|
| 20 | return (value, index) => {
|
|---|
| 21 | if (isNumber(minPointSize)) return minPointSize;
|
|---|
| 22 | var isValueNumberOrNil = isNumber(value) || isNullish(value);
|
|---|
| 23 | if (isValueNumberOrNil) {
|
|---|
| 24 | return minPointSize(value, index);
|
|---|
| 25 | }
|
|---|
| 26 | !isValueNumberOrNil ? true ? invariant(false, "minPointSize callback function received a value with type of ".concat(typeof value, ". Currently only numbers or null/undefined are supported.")) : invariant(false) : void 0;
|
|---|
| 27 | return defaultValue;
|
|---|
| 28 | };
|
|---|
| 29 | }; |
|---|