UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

106 lines (105 loc) 3.21 kB
'use client'; import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; const _excluded = ["seriesId", "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 "./barClasses.mjs"; import { useItemHighlightState } from "../hooks/useItemHighlightState.mjs"; import { AnimatedBarElement } from "./AnimatedBarElement.mjs"; import { useIsItemFocused } from "../hooks/useIsItemFocused.mjs"; import { jsx as _jsx } from "react/jsx-runtime"; function BarElement(props) { const { seriesId, 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, dataIndex }), [seriesId, dataIndex]); const highlightState = useItemHighlightState(itemIdentifier); const isHighlighted = highlightState === 'highlighted'; const isFaded = highlightState === 'faded'; const isFocused = useIsItemFocused(itemIdentifier); const ownerState = { seriesId, 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: { seriesId, dataIndex, color, x, xOrigin, y, yOrigin, width, height, style, onClick, cursor: onClick ? 'pointer' : undefined, stroke: 'none', fill: color, skipAnimation, layout, hidden }, className: classes.element, 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, layout: PropTypes.oneOf(['horizontal', 'vertical']).isRequired, seriesId: PropTypes.string.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 };