UNPKG

@mui/x-charts

Version:

The community edition of the charts components (MUI X).

59 lines (58 loc) 2.64 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.ChartsClipPath = ChartsClipPath; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var React = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _DrawingProvider = require("../context/DrawingProvider"); var _jsxRuntime = require("react/jsx-runtime"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** * API: * * - [ChartsClipPath API](https://mui.com/x/api/charts/charts-clip-path/) */ function ChartsClipPath(props) { const { id, offset: offsetProps } = props; const { left, top, width, height } = React.useContext(_DrawingProvider.DrawingContext); const offset = (0, _extends2.default)({ top: 0, right: 0, bottom: 0, left: 0 }, offsetProps); return /*#__PURE__*/(0, _jsxRuntime.jsx)("clipPath", { id: id, children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", { x: left - offset.left, y: top - offset.top, width: width + offset.left + offset.right, height: height + offset.top + offset.bottom }) }); } process.env.NODE_ENV !== "production" ? ChartsClipPath.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- id: _propTypes.default.string.isRequired, offset: _propTypes.default.shape({ bottom: _propTypes.default.number, left: _propTypes.default.number, right: _propTypes.default.number, top: _propTypes.default.number }) } : void 0;