UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

103 lines (102 loc) 3.6 kB
'use client'; import _extends from "@babel/runtime/helpers/esm/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; const _excluded = ["seriesId", "classes", "color", "gradientId", "slots", "slotProps", "onClick", "hidden"]; import * as React from 'react'; import PropTypes from 'prop-types'; import useSlotProps from '@mui/utils/useSlotProps'; import { useInteractionItemProps } from "../hooks/useInteractionItemProps.mjs"; import { AnimatedLine } from "./AnimatedLine.mjs"; import { useItemHighlightState } from "../hooks/useItemHighlightState.mjs"; import { selectorChartExperimentalFeaturesState } from "../internals/plugins/corePlugins/useChartExperimentalFeature/index.mjs"; import { useStore } from "../internals/store/useStore.mjs"; import { useUtilityClasses as useLineUtilityClasses } from "./lineClasses.mjs"; import { jsx as _jsx } from "react/jsx-runtime"; /** * Demos: * * - [Lines](https://mui.com/x/react-charts/lines/) * - [Line demonstration](https://mui.com/x/react-charts/line-demo/) * * API: * * - [LineElement API](https://mui.com/x/api/charts/line-element/) */ function LineElement(props) { const { seriesId, classes: innerClasses, color, gradientId, slots, slotProps, onClick, hidden } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const store = useStore(); const enablePositionBasedPointerInteraction = store.use(selectorChartExperimentalFeaturesState)?.enablePositionBasedPointerInteraction; const identifier = React.useMemo(() => ({ type: 'line', seriesId }), [seriesId]); const interactionProps = useInteractionItemProps(identifier); const highlightState = useItemHighlightState(identifier); const isHighlighted = highlightState === 'highlighted'; const isFaded = highlightState === 'faded'; const ownerState = { seriesId, classes: innerClasses, color, gradientId, isFaded, isHighlighted, hidden }; const classes = useLineUtilityClasses(); const Line = slots?.line ?? AnimatedLine; const lineProps = useSlotProps({ elementType: Line, externalSlotProps: slotProps?.line, additionalProps: _extends({}, enablePositionBasedPointerInteraction ? {} : interactionProps, { onClick, cursor: onClick ? 'pointer' : 'unset', 'data-highlighted': isHighlighted || undefined, 'data-faded': isFaded || undefined, 'data-series-id': seriesId, 'data-series': seriesId }), className: classes.line, ownerState }); return /*#__PURE__*/_jsx(Line, _extends({}, other, lineProps)); } process.env.NODE_ENV !== "production" ? LineElement.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, color: PropTypes.string.isRequired, d: PropTypes.string.isRequired, gradientId: PropTypes.string, /** If `true`, the line is hidden. */ hidden: PropTypes.bool, seriesId: PropTypes.string.isRequired, /** * If `true`, animations are skipped. * @default false */ skipAnimation: PropTypes.bool, /** * The props used for each component slot. * @default {} */ slotProps: PropTypes.object, /** * Overridable component slots. * @default {} */ slots: PropTypes.object } : void 0; export { LineElement };