106 lines
3.0 KiB
JavaScript
106 lines
3.0 KiB
JavaScript
'use client';
|
|
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
const _excluded = ["id", "dataIndex", "classes", "color", "slots", "slotProps", "style", "onClick", "skipAnimation", "layout", "x", "xOrigin", "y", "yOrigin", "width", "height"];
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
import { useUtilityClasses } from "./barElementClasses.js";
|
|
import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
|
|
import { useItemHighlighted } from "../hooks/useItemHighlighted.js";
|
|
import { AnimatedBarElement } from "./AnimatedBarElement.js";
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
function BarElement(props) {
|
|
const {
|
|
id,
|
|
dataIndex,
|
|
classes: innerClasses,
|
|
color,
|
|
slots,
|
|
slotProps,
|
|
style,
|
|
onClick,
|
|
skipAnimation,
|
|
layout,
|
|
x,
|
|
xOrigin,
|
|
y,
|
|
yOrigin,
|
|
width,
|
|
height
|
|
} = props,
|
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
const interactionProps = useInteractionItemProps({
|
|
type: 'bar',
|
|
seriesId: id,
|
|
dataIndex
|
|
});
|
|
const {
|
|
isFaded,
|
|
isHighlighted
|
|
} = useItemHighlighted({
|
|
seriesId: id,
|
|
dataIndex
|
|
});
|
|
const ownerState = {
|
|
id,
|
|
dataIndex,
|
|
classes: innerClasses,
|
|
color,
|
|
isFaded,
|
|
isHighlighted
|
|
};
|
|
const classes = useUtilityClasses(ownerState);
|
|
const Bar = slots?.bar ?? AnimatedBarElement;
|
|
const barProps = useSlotProps({
|
|
elementType: Bar,
|
|
externalSlotProps: slotProps?.bar,
|
|
externalForwardedProps: other,
|
|
additionalProps: _extends({}, interactionProps, {
|
|
id,
|
|
dataIndex,
|
|
color,
|
|
x,
|
|
xOrigin,
|
|
y,
|
|
yOrigin,
|
|
width,
|
|
height,
|
|
style,
|
|
onClick,
|
|
cursor: onClick ? 'pointer' : 'unset',
|
|
stroke: 'none',
|
|
fill: color,
|
|
skipAnimation,
|
|
layout
|
|
}),
|
|
className: classes.root,
|
|
ownerState
|
|
});
|
|
return /*#__PURE__*/_jsx(Bar, _extends({}, barProps));
|
|
}
|
|
process.env.NODE_ENV !== "production" ? BarElement.propTypes = {
|
|
// ----------------------------- Warning --------------------------------
|
|
// | These PropTypes are generated from the TypeScript type definitions |
|
|
// | To update them edit the TypeScript types and run "pnpm proptypes" |
|
|
// ----------------------------------------------------------------------
|
|
classes: PropTypes.object,
|
|
dataIndex: PropTypes.number.isRequired,
|
|
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
|
|
layout: PropTypes.oneOf(['horizontal', 'vertical']).isRequired,
|
|
skipAnimation: PropTypes.bool.isRequired,
|
|
/**
|
|
* The props used for each component slot.
|
|
* @default {}
|
|
*/
|
|
slotProps: PropTypes.object,
|
|
/**
|
|
* Overridable component slots.
|
|
* @default {}
|
|
*/
|
|
slots: PropTypes.object,
|
|
xOrigin: PropTypes.number.isRequired,
|
|
yOrigin: PropTypes.number.isRequired
|
|
} : void 0;
|
|
export { BarElement }; |