@patternfly/react-charts
Version:
This library provides a set of React chart components for use with the PatternFly reference implementation.
32 lines • 2.17 kB
JavaScript
import { __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { cloneElement } from 'react';
import chart_global_label_Fill from '@patternfly/react-tokens/dist/esm/chart_global_label_Fill';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { LineSegment } from 'victory-core';
import { VictoryCursorContainer } from 'victory-cursor-container';
import { ChartLabel } from '../ChartLabel/ChartLabel';
import { getComponentTheme, getTheme } from '../ChartUtils/chart-theme';
import { getClassName } from '../ChartUtils/chart-helpers';
export const ChartCursorContainer = (_a) => {
var { className, cursorComponent = _jsx(LineSegment, {}), themeColor,
// destructure last
theme = getTheme(themeColor), cursorLabelComponent = _jsx(ChartLabel, {}) } = _a, // Note that Victory provides its own label component here
rest = __rest(_a, ["className", "cursorComponent", "themeColor", "theme", "cursorLabelComponent"]);
const componentTheme = getComponentTheme(themeColor);
const chartClassName = getClassName({ className });
const chartCursorLabelComponent = cloneElement(cursorLabelComponent, Object.assign(Object.assign({ theme }, cursorLabelComponent.props), ((componentTheme === null || componentTheme === void 0 ? void 0 : componentTheme.label) && componentTheme.label) // override backgroundStyle
));
// Clone so users can override cursor container props
const cursor = cloneElement(cursorComponent, Object.assign({ style: {
strokeColor: chart_global_label_Fill.var
} }, cursorComponent.props));
// Note: theme is required by voronoiContainerMixin
return (
// Note: className is valid, but Victory is missing a type
_jsx(VictoryCursorContainer, Object.assign({ className: chartClassName, cursorComponent: cursor, cursorLabelComponent: chartCursorLabelComponent, theme: theme }, rest)));
};
ChartCursorContainer.displayName = 'ChartCursorContainer';
// Note: VictoryCursorContainer.defaultEvents & VictoryContainer.role must be hoisted
hoistNonReactStatics(ChartCursorContainer, VictoryCursorContainer);
//# sourceMappingURL=ChartCursorContainer.js.map