61 lines
1.6 KiB
JavaScript
61 lines
1.6 KiB
JavaScript
'use client';
|
|
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
/**
|
|
* 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
|
|
} = useDrawingArea();
|
|
const offset = _extends({
|
|
top: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
left: 0
|
|
}, offsetProps);
|
|
return /*#__PURE__*/_jsx("clipPath", {
|
|
id: id,
|
|
children: /*#__PURE__*/_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 "pnpm proptypes" |
|
|
// ----------------------------------------------------------------------
|
|
/**
|
|
* The id of the clip path.
|
|
*/
|
|
id: PropTypes.string.isRequired,
|
|
/**
|
|
* Offset, in pixels, of the clip path rectangle from the drawing area.
|
|
*
|
|
* A positive value will move the rectangle outside the drawing area.
|
|
*/
|
|
offset: PropTypes.shape({
|
|
bottom: PropTypes.number,
|
|
left: PropTypes.number,
|
|
right: PropTypes.number,
|
|
top: PropTypes.number
|
|
})
|
|
} : void 0;
|
|
export { ChartsClipPath }; |