| 1 | var _excluded = ["component"];
|
|---|
| 2 | function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|---|
| 3 | function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|---|
| 4 | /**
|
|---|
| 5 | * @fileOverview Customized
|
|---|
| 6 | */
|
|---|
| 7 | import * as React from 'react';
|
|---|
| 8 | import { isValidElement, cloneElement, createElement } from 'react';
|
|---|
| 9 | import { Layer } from '../container/Layer';
|
|---|
| 10 | import { warn } from '../util/LogUtils';
|
|---|
| 11 | /**
|
|---|
| 12 | * Customized component used to be necessary to render custom elements in Recharts 2.x.
|
|---|
| 13 | * Starting from Recharts 3.x, all charts are able to render arbitrary elements anywhere,
|
|---|
| 14 | * and Customized is no longer needed.
|
|---|
| 15 | *
|
|---|
| 16 | * @example Before: `<Customized component={<MyCustomComponent />} />`
|
|---|
| 17 | * @example After: `<MyCustomComponent />`
|
|---|
| 18 | *
|
|---|
| 19 | * @deprecated Just render your components directly. Will be removed in 4.0
|
|---|
| 20 | */
|
|---|
| 21 | export function Customized(_ref) {
|
|---|
| 22 | var {
|
|---|
| 23 | component
|
|---|
| 24 | } = _ref,
|
|---|
| 25 | props = _objectWithoutProperties(_ref, _excluded);
|
|---|
| 26 | var child;
|
|---|
| 27 | if (/*#__PURE__*/isValidElement(component)) {
|
|---|
| 28 | child = /*#__PURE__*/cloneElement(component, props);
|
|---|
| 29 | } else if (typeof component === 'function') {
|
|---|
| 30 | // @ts-expect-error TS cannot verify that C is FunctionComponent<P> here
|
|---|
| 31 | child = /*#__PURE__*/createElement(component, props);
|
|---|
| 32 | } else {
|
|---|
| 33 | warn(false, "Customized's props `component` must be React.element or Function, but got %s.", typeof component);
|
|---|
| 34 | }
|
|---|
| 35 | return /*#__PURE__*/React.createElement(Layer, {
|
|---|
| 36 | className: "recharts-customized-wrapper"
|
|---|
| 37 | }, child);
|
|---|
| 38 | }
|
|---|
| 39 | Customized.displayName = 'Customized'; |
|---|