UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

113 lines (112 loc) 3.38 kB
'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", "hidden"]; 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 { useIsItemFocused } from "../hooks/useIsItemFocused.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, hidden } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const itemIdentifier = React.useMemo(() => ({ type: 'bar', seriesId: id, dataIndex }), [id, dataIndex]); const interactionProps = useInteractionItemProps(itemIdentifier); const { isFaded, isHighlighted } = useItemHighlighted(itemIdentifier); const isFocused = useIsItemFocused(React.useMemo(() => ({ type: 'bar', seriesId: id, dataIndex }), [id, dataIndex])); const ownerState = { id, dataIndex, classes: innerClasses, color, isFaded, isHighlighted, isFocused }; 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, hidden }), 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 };