111 lines
3.4 KiB
JavaScript
111 lines
3.4 KiB
JavaScript
'use client';
|
|
|
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
const _excluded = ["id", "classes", "color", "gradientId", "slots", "slotProps", "onClick"];
|
|
import * as React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import composeClasses from '@mui/utils/composeClasses';
|
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
import { useInteractionItemProps } from "../hooks/useInteractionItemProps.js";
|
|
import { AnimatedLine } from "./AnimatedLine.js";
|
|
import { useItemHighlighted } from "../hooks/useItemHighlighted.js";
|
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
export function getLineElementUtilityClass(slot) {
|
|
return generateUtilityClass('MuiLineElement', slot);
|
|
}
|
|
export const lineElementClasses = generateUtilityClasses('MuiLineElement', ['root', 'highlighted', 'faded', 'series']);
|
|
const useUtilityClasses = ownerState => {
|
|
const {
|
|
classes,
|
|
id,
|
|
isFaded,
|
|
isHighlighted
|
|
} = ownerState;
|
|
const slots = {
|
|
root: ['root', `series-${id}`, isHighlighted && 'highlighted', isFaded && 'faded']
|
|
};
|
|
return composeClasses(slots, getLineElementUtilityClass, classes);
|
|
};
|
|
/**
|
|
* 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 {
|
|
id,
|
|
classes: innerClasses,
|
|
color,
|
|
gradientId,
|
|
slots,
|
|
slotProps,
|
|
onClick
|
|
} = props,
|
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
const interactionProps = useInteractionItemProps({
|
|
type: 'line',
|
|
seriesId: id
|
|
});
|
|
const {
|
|
isFaded,
|
|
isHighlighted
|
|
} = useItemHighlighted({
|
|
seriesId: id
|
|
});
|
|
const ownerState = {
|
|
id,
|
|
classes: innerClasses,
|
|
color,
|
|
gradientId,
|
|
isFaded,
|
|
isHighlighted
|
|
};
|
|
const classes = useUtilityClasses(ownerState);
|
|
const Line = slots?.line ?? AnimatedLine;
|
|
const lineProps = useSlotProps({
|
|
elementType: Line,
|
|
externalSlotProps: slotProps?.line,
|
|
additionalProps: _extends({}, interactionProps, {
|
|
onClick,
|
|
cursor: onClick ? 'pointer' : 'unset'
|
|
}),
|
|
className: classes.root,
|
|
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,
|
|
id: PropTypes.oneOfType([PropTypes.number, 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 }; |