108 lines
4.3 KiB
JavaScript
108 lines
4.3 KiB
JavaScript
"use strict";
|
|
'use client';
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.ChartsSurface = void 0;
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
var _styles = require("@mui/material/styles");
|
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
var React = _interopRequireWildcard(require("react"));
|
|
var _useForkRef = _interopRequireDefault(require("@mui/utils/useForkRef"));
|
|
var _ChartsAxesGradients = require("../internals/components/ChartsAxesGradients");
|
|
var _useSvgRef = require("../hooks/useSvgRef");
|
|
var _useSelector = require("../internals/store/useSelector");
|
|
var _useStore = require("../internals/store/useStore");
|
|
var _useChartDimensions = require("../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors");
|
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
const _excluded = ["children", "className", "title", "desc"];
|
|
const ChartsSurfaceStyles = (0, _styles.styled)('svg', {
|
|
name: 'MuiChartsSurface',
|
|
slot: 'Root'
|
|
})(({
|
|
ownerState
|
|
}) => ({
|
|
width: ownerState.width ?? '100%',
|
|
height: ownerState.height ?? '100%',
|
|
display: 'flex',
|
|
position: 'relative',
|
|
flexDirection: 'column',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
overflow: 'hidden',
|
|
// This prevents default touch actions when using the svg on mobile devices.
|
|
// For example, prevent page scroll & zoom.
|
|
touchAction: 'pan-y',
|
|
userSelect: 'none'
|
|
}));
|
|
|
|
/**
|
|
* It provides the drawing area for the chart elements.
|
|
* It is the root `<svg>` of all the chart elements.
|
|
*
|
|
* It also provides the `title` and `desc` elements for the chart.
|
|
*
|
|
* Demos:
|
|
*
|
|
* - [Composition](https://mui.com/x/api/charts/composition/)
|
|
*
|
|
* API:
|
|
*
|
|
* - [ChartsSurface API](https://mui.com/x/api/charts/charts-surface/)
|
|
*/
|
|
const ChartsSurface = exports.ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(inProps, ref) {
|
|
const store = (0, _useStore.useStore)();
|
|
const {
|
|
width: svgWidth,
|
|
height: svgHeight
|
|
} = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartContainerSize);
|
|
const {
|
|
width: propsWidth,
|
|
height: propsHeight
|
|
} = (0, _useSelector.useSelector)(store, _useChartDimensions.selectorChartPropsSize);
|
|
const svgRef = (0, _useSvgRef.useSvgRef)();
|
|
const handleRef = (0, _useForkRef.default)(svgRef, ref);
|
|
const themeProps = (0, _styles.useThemeProps)({
|
|
props: inProps,
|
|
name: 'MuiChartsSurface'
|
|
});
|
|
const {
|
|
children,
|
|
className,
|
|
title,
|
|
desc
|
|
} = themeProps,
|
|
other = (0, _objectWithoutPropertiesLoose2.default)(themeProps, _excluded);
|
|
const hasIntrinsicSize = svgHeight > 0 && svgWidth > 0;
|
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(ChartsSurfaceStyles, (0, _extends2.default)({
|
|
ownerState: {
|
|
width: propsWidth,
|
|
height: propsHeight
|
|
},
|
|
viewBox: `${0} ${0} ${svgWidth} ${svgHeight}`,
|
|
className: className
|
|
}, other, {
|
|
ref: handleRef,
|
|
children: [title && /*#__PURE__*/(0, _jsxRuntime.jsx)("title", {
|
|
children: title
|
|
}), desc && /*#__PURE__*/(0, _jsxRuntime.jsx)("desc", {
|
|
children: desc
|
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxesGradients.ChartsAxesGradients, {}), hasIntrinsicSize && children]
|
|
}));
|
|
});
|
|
if (process.env.NODE_ENV !== "production") ChartsSurface.displayName = "ChartsSurface";
|
|
process.env.NODE_ENV !== "production" ? ChartsSurface.propTypes = {
|
|
// ----------------------------- Warning --------------------------------
|
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
// ----------------------------------------------------------------------
|
|
children: _propTypes.default.node,
|
|
className: _propTypes.default.string,
|
|
desc: _propTypes.default.string,
|
|
sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
|
|
title: _propTypes.default.string
|
|
} : void 0; |