@neo4j-ndl/react-charts
Version:
React implementation of charts from Neo4j Design System
49 lines • 3.47 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { Popover, StatusIndicator, TextLink, Typography, } from '@neo4j-ndl/react';
import classNames from 'classnames';
import { forwardRef } from 'react';
export const ChartTooltipComponent = forwardRef(function ChartTooltipComponent({ children, isOpen, style, anchorPosition }, ref) {
return (_jsx(Popover, { isOpen: isOpen, anchorPosition: anchorPosition, placement: "middle-end-middle-start", children: _jsx(Popover.Content, { ref: ref, style: style, children: children }) }));
});
const ChartTooltipTitle = forwardRef(function ChartTooltipTitle({ children }, ref) {
const classes = classNames(`ndl-charts-chart-tooltip-title`);
return (_jsx(Typography, { ref: ref, variant: "body-small", className: classes, children: children }));
});
const ChartTooltipContent = forwardRef(function ChartTooltipContent({ leftElement, rightElement, indentSquareColor, notifications, }, ref) {
const classes = classNames(`ndl-charts-chart-tooltip-content`);
return (_jsxs("div", { ref: ref, className: classes, children: [_jsxs("div", { className: "ndl-charts-chart-tooltip-content-line", children: [indentSquareColor && (_jsx("div", { className: "ndl-charts-chart-tooltip-content-indent-square", style: { backgroundColor: indentSquareColor } })), leftElement && (_jsx(Typography, { variant: rightElement ? 'body-medium' : 'label', className: "ndl-charts-chart-tooltip-content-left-element", children: leftElement })), rightElement && (_jsx(Typography, { variant: "label", className: "ndl-charts-chart-tooltip-content-right-element", children: rightElement }))] }), notifications &&
notifications.map((notification) => {
const { id, notificationType, leftElement, rightElement } = notification;
return (_jsxs("div", { className: `ndl-charts-chart-tooltip-content-notification ndl-notification-${notificationType}`, children: [_jsx(StatusIndicator, { type: notificationType }), _jsx(Typography, { variant: "body-medium", className: "ndl-charts-chart-tooltip-content-notification-left-element", children: leftElement }), _jsx(Typography, { variant: "label", className: "ndl-charts-chart-tooltip-content-notification-right-element", children: rightElement })] }, `notification-${id}`));
})] }));
});
const ChartTooltipLink = forwardRef(function ChartTooltipAction(props, ref) {
return _jsx(TextLink, Object.assign({ ref: ref }, props));
});
const ChartTooltip = Object.assign(ChartTooltipComponent, {
Title: ChartTooltipTitle,
Content: ChartTooltipContent,
Link: ChartTooltipLink,
});
export { ChartTooltip };
//# sourceMappingURL=ChartTooltip.js.map