@neo4j-ndl/react-charts
Version:
React implementation of charts from Neo4j Design System
60 lines • 3.97 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
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';
export const ChartTooltipComponent = 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 = 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 = function ChartTooltipContent({ leadingElement, trailingElement, 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 } })), leadingElement && (_jsx(Typography, { variant: trailingElement ? 'body-medium' : 'label', className: "ndl-charts-chart-tooltip-content-left-element", children: leadingElement })), trailingElement && (_jsx(Typography, { variant: "label", className: "ndl-charts-chart-tooltip-content-trailing-element", children: trailingElement }))] }), notifications &&
notifications.map((notification) => {
const { id, notificationType, leadingElement, trailingElement } = notification;
return (_jsxs("div", { className: `ndl-charts-chart-tooltip-content-notification ndl-notification-${notificationType}`, children: [_jsx(StatusIndicator, { variant: notificationType }), _jsx(Typography, { variant: "body-medium", className: "ndl-charts-chart-tooltip-content-notification-left-element", children: leadingElement }), _jsx(Typography, { variant: "label", className: "ndl-charts-chart-tooltip-content-notification-trailing-element", children: trailingElement })] }, `notification-${id}`));
})] }));
};
const ChartTooltipLink = function ChartTooltipAction(_a) {
var { ref } = _a, restProps = __rest(_a, ["ref"]);
return _jsx(TextLink, Object.assign({ ref: ref }, restProps));
};
const ChartTooltip = Object.assign(ChartTooltipComponent, {
Content: ChartTooltipContent,
Link: ChartTooltipLink,
Title: ChartTooltipTitle,
});
export { ChartTooltip };
//# sourceMappingURL=ChartTooltip.js.map