UNPKG

@patternfly/react-charts

Version:

This library provides a set of React chart components for use with the PatternFly reference implementation.

37 lines 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChartCursorContainer = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); /* eslint-disable camelcase */ const react_1 = require("react"); const chart_global_label_Fill_1 = tslib_1.__importDefault(require('@patternfly/react-tokens/dist/js/chart_global_label_Fill')); const hoist_non_react_statics_1 = tslib_1.__importDefault(require("hoist-non-react-statics")); const victory_core_1 = require("victory-core"); const victory_cursor_container_1 = require("victory-cursor-container"); const ChartLabel_1 = require("../ChartLabel/ChartLabel"); const chart_theme_1 = require("../ChartUtils/chart-theme"); const chart_helpers_1 = require("../ChartUtils/chart-helpers"); const ChartCursorContainer = (_a) => { var { className, cursorComponent = (0, jsx_runtime_1.jsx)(victory_core_1.LineSegment, {}), themeColor, // destructure last theme = (0, chart_theme_1.getTheme)(themeColor), cursorLabelComponent = (0, jsx_runtime_1.jsx)(ChartLabel_1.ChartLabel, {}) } = _a, // Note that Victory provides its own label component here rest = tslib_1.__rest(_a, ["className", "cursorComponent", "themeColor", "theme", "cursorLabelComponent"]); const componentTheme = (0, chart_theme_1.getComponentTheme)(themeColor); const chartClassName = (0, chart_helpers_1.getClassName)({ className }); const chartCursorLabelComponent = (0, react_1.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 = (0, react_1.cloneElement)(cursorComponent, Object.assign({ style: { strokeColor: chart_global_label_Fill_1.default.var } }, cursorComponent.props)); // Note: theme is required by voronoiContainerMixin return ( // Note: className is valid, but Victory is missing a type (0, jsx_runtime_1.jsx)(victory_cursor_container_1.VictoryCursorContainer, Object.assign({ className: chartClassName, cursorComponent: cursor, cursorLabelComponent: chartCursorLabelComponent, theme: theme }, rest))); }; exports.ChartCursorContainer = ChartCursorContainer; exports.ChartCursorContainer.displayName = 'ChartCursorContainer'; // Note: VictoryCursorContainer.defaultEvents & VictoryContainer.role must be hoisted (0, hoist_non_react_statics_1.default)(exports.ChartCursorContainer, victory_cursor_container_1.VictoryCursorContainer); //# sourceMappingURL=ChartCursorContainer.js.map