@monolith-forensics/monolith-ui 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +0 -4
  2. package/dist/Tabs/Tab.js +0 -8
  3. package/dist/TagBox/TagBox.d.ts +1 -1
  4. package/dist/TagBox/TagBox.js +135 -35
  5. package/dist/TagBox/types.d.ts +13 -0
  6. package/dist/core/controlSizes.d.ts +0 -26
  7. package/dist/core/controlSizes.js +0 -156
  8. package/dist/core/index.d.ts +1 -0
  9. package/dist/core/index.js +1 -0
  10. package/dist/theme/variants.js +0 -8
  11. package/package.json +1 -1
  12. package/dist/Charts/BarChart/BarChart.d.ts +0 -5
  13. package/dist/Charts/BarChart/BarChart.js +0 -563
  14. package/dist/Charts/BarChart/BarChart.lib.d.ts +0 -31
  15. package/dist/Charts/BarChart/BarChart.lib.js +0 -136
  16. package/dist/Charts/BarChart/BarChart.styled.d.ts +0 -56
  17. package/dist/Charts/BarChart/BarChart.styled.js +0 -119
  18. package/dist/Charts/BarChart/BarChart.types.d.ts +0 -179
  19. package/dist/Charts/BarChart/BarChart.types.js +0 -1
  20. package/dist/Charts/BarChart/index.d.ts +0 -3
  21. package/dist/Charts/BarChart/index.js +0 -2
  22. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +0 -11
  23. package/dist/Charts/ChartPrimitives/ChartExportControl.js +0 -29
  24. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +0 -1
  25. package/dist/Charts/ChartPrimitives/chartActions.styled.js +0 -8
  26. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +0 -12
  27. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +0 -52
  28. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +0 -19
  29. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +0 -61
  30. package/dist/Charts/ChartPrimitives/index.d.ts +0 -4
  31. package/dist/Charts/ChartPrimitives/index.js +0 -4
  32. package/dist/Charts/ChartUtils/chartColors.d.ts +0 -8
  33. package/dist/Charts/ChartUtils/chartColors.js +0 -65
  34. package/dist/Charts/ChartUtils/chartExport.d.ts +0 -47
  35. package/dist/Charts/ChartUtils/chartExport.js +0 -311
  36. package/dist/Charts/ChartUtils/chartMath.d.ts +0 -3
  37. package/dist/Charts/ChartUtils/chartMath.js +0 -3
  38. package/dist/Charts/ChartUtils/chartSizing.d.ts +0 -20
  39. package/dist/Charts/ChartUtils/chartSizing.js +0 -83
  40. package/dist/Charts/ChartUtils/index.d.ts +0 -4
  41. package/dist/Charts/ChartUtils/index.js +0 -4
  42. package/dist/Charts/HeatMap/HeatMap.d.ts +0 -5
  43. package/dist/Charts/HeatMap/HeatMap.js +0 -233
  44. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +0 -30
  45. package/dist/Charts/HeatMap/HeatMap.lib.js +0 -115
  46. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +0 -41
  47. package/dist/Charts/HeatMap/HeatMap.styled.js +0 -94
  48. package/dist/Charts/HeatMap/HeatMap.types.d.ts +0 -86
  49. package/dist/Charts/HeatMap/HeatMap.types.js +0 -1
  50. package/dist/Charts/HeatMap/index.d.ts +0 -3
  51. package/dist/Charts/HeatMap/index.js +0 -2
  52. package/dist/Charts/LineChart/LineChart.d.ts +0 -5
  53. package/dist/Charts/LineChart/LineChart.js +0 -548
  54. package/dist/Charts/LineChart/LineChart.lib.d.ts +0 -24
  55. package/dist/Charts/LineChart/LineChart.lib.js +0 -132
  56. package/dist/Charts/LineChart/LineChart.styled.d.ts +0 -64
  57. package/dist/Charts/LineChart/LineChart.styled.js +0 -151
  58. package/dist/Charts/LineChart/LineChart.types.d.ts +0 -201
  59. package/dist/Charts/LineChart/LineChart.types.js +0 -1
  60. package/dist/Charts/LineChart/index.d.ts +0 -3
  61. package/dist/Charts/LineChart/index.js +0 -2
  62. package/dist/Charts/PieChart/PieChart.d.ts +0 -4
  63. package/dist/Charts/PieChart/PieChart.js +0 -214
  64. package/dist/Charts/PieChart/PieChart.lib.d.ts +0 -5
  65. package/dist/Charts/PieChart/PieChart.lib.js +0 -19
  66. package/dist/Charts/PieChart/PieChart.styled.d.ts +0 -56
  67. package/dist/Charts/PieChart/PieChart.styled.js +0 -168
  68. package/dist/Charts/PieChart/PieChart.types.d.ts +0 -104
  69. package/dist/Charts/PieChart/PieChart.types.js +0 -1
  70. package/dist/Charts/PieChart/index.d.ts +0 -2
  71. package/dist/Charts/PieChart/index.js +0 -1
  72. package/dist/Charts/index.d.ts +0 -5
  73. package/dist/Charts/index.js +0 -4
  74. package/dist/QueryFilter/QueryFilter.constants.d.ts +0 -134
  75. package/dist/QueryFilter/QueryFilter.constants.js +0 -39
  76. package/dist/QueryFilter/QueryFilter.lib.d.ts +0 -14
  77. package/dist/QueryFilter/QueryFilter.lib.js +0 -84
  78. package/dist/QueryFilter/QueryFilter.styled.d.ts +0 -89
  79. package/dist/QueryFilter/QueryFilter.styled.js +0 -184
  80. package/dist/QueryFilter/QueryFilter.types.d.ts +0 -61
  81. package/dist/QueryFilter/QueryFilter.types.js +0 -1
  82. package/dist/QueryFilter/components/MultiSelectEditor.d.ts +0 -7
  83. package/dist/QueryFilter/components/MultiSelectEditor.js +0 -44
  84. package/dist/QueryFilter/components/RuleChip.d.ts +0 -8
  85. package/dist/QueryFilter/components/RuleChip.js +0 -37
  86. package/dist/QueryFilter/components/Rules.d.ts +0 -11
  87. package/dist/QueryFilter/components/Rules.js +0 -41
  88. package/dist/QueryFilter/components/UnavailableRuleChip.d.ts +0 -5
  89. package/dist/QueryFilter/components/UnavailableRuleChip.js +0 -7
  90. package/dist/QueryFilter/components/ValueEditor.d.ts +0 -7
  91. package/dist/QueryFilter/components/ValueEditor.js +0 -45
  92. package/dist/QueryFilter/components/ValueSelector.d.ts +0 -7
  93. package/dist/QueryFilter/components/ValueSelector.js +0 -34
  94. package/dist/QueryFilter/components/index.d.ts +0 -6
  95. package/dist/QueryFilter/components/index.js +0 -6
  96. package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +0 -18
  97. package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +0 -6
  98. package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +0 -9
  99. package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +0 -42
  100. package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +0 -10
  101. package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +0 -60
  102. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +0 -9
  103. package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +0 -30
  104. package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +0 -3
  105. package/dist/RichTextEditor/Components/CodeBlockNodeView.js +0 -28
  106. package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +0 -10
  107. package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +0 -17
  108. package/dist/RichTextEditor/Components/LinkEditor.d.ts +0 -8
  109. package/dist/RichTextEditor/Components/LinkEditor.js +0 -94
  110. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.d.ts +0 -2
  111. package/dist/RichTextEditor/Components/TableTools/TableCornerMenu.js +0 -19
  112. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.d.ts +0 -2
  113. package/dist/RichTextEditor/Components/TableTools/TableInsertControls.js +0 -24
  114. package/dist/RichTextEditor/Components/TableTools/TableRails.d.ts +0 -2
  115. package/dist/RichTextEditor/Components/TableTools/TableRails.js +0 -180
  116. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.d.ts +0 -5
  117. package/dist/RichTextEditor/Components/TableTools/TableToolMenu.js +0 -6
  118. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.d.ts +0 -5
  119. package/dist/RichTextEditor/Components/TableTools/TableTools.actions.js +0 -183
  120. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.d.ts +0 -16
  121. package/dist/RichTextEditor/Components/TableTools/TableTools.commands.js +0 -217
  122. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.d.ts +0 -8
  123. package/dist/RichTextEditor/Components/TableTools/TableTools.constants.js +0 -11
  124. package/dist/RichTextEditor/Components/TableTools/TableTools.d.ts +0 -3
  125. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.d.ts +0 -23
  126. package/dist/RichTextEditor/Components/TableTools/TableTools.geometry.js +0 -75
  127. package/dist/RichTextEditor/Components/TableTools/TableTools.js +0 -3
  128. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.d.ts +0 -16
  129. package/dist/RichTextEditor/Components/TableTools/TableTools.selectors.js +0 -53
  130. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.d.ts +0 -40
  131. package/dist/RichTextEditor/Components/TableTools/TableTools.styled.js +0 -167
  132. package/dist/RichTextEditor/Components/TableTools/TableTools.types.d.ts +0 -76
  133. package/dist/RichTextEditor/Components/TableTools/TableTools.types.js +0 -1
  134. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.d.ts +0 -4
  135. package/dist/RichTextEditor/Components/TableTools/TableTools.utils.js +0 -4
  136. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.d.ts +0 -2
  137. package/dist/RichTextEditor/Components/TableTools/TableToolsPopover.js +0 -12
  138. package/dist/RichTextEditor/Components/TableTools/index.d.ts +0 -3
  139. package/dist/RichTextEditor/Components/TableTools/index.js +0 -2
  140. package/dist/RichTextEditor/Enums/HighlightColors.d.ts +0 -9
  141. package/dist/RichTextEditor/Enums/HighlightColors.js +0 -10
  142. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.d.ts +0 -3
  143. package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +0 -238
  144. package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +0 -20
  145. package/dist/RichTextEditor/Utils/codeBlockUtils.js +0 -137
  146. package/dist/RichTextEditor/Utils/codeUtils.d.ts +0 -3
  147. package/dist/RichTextEditor/Utils/codeUtils.js +0 -12
  148. package/dist/RichTextEditor/Utils/linkUtils.d.ts +0 -19
  149. package/dist/RichTextEditor/Utils/linkUtils.js +0 -57
  150. package/dist/RichTextEditor/Utils/tableUtils.d.ts +0 -1
  151. package/dist/RichTextEditor/Utils/tableUtils.js +0 -1
  152. package/dist/SuperDatePicker/SuperDatePicker.constants.d.ts +0 -24
  153. package/dist/SuperDatePicker/SuperDatePicker.constants.js +0 -30
  154. package/dist/SuperDatePicker/SuperDatePicker.d.ts +0 -3
  155. package/dist/SuperDatePicker/SuperDatePicker.js +0 -31
  156. package/dist/SuperDatePicker/SuperDatePicker.lib.d.ts +0 -17
  157. package/dist/SuperDatePicker/SuperDatePicker.lib.js +0 -206
  158. package/dist/SuperDatePicker/SuperDatePicker.styled.d.ts +0 -60
  159. package/dist/SuperDatePicker/SuperDatePicker.styled.js +0 -256
  160. package/dist/SuperDatePicker/SuperDatePicker.types.d.ts +0 -48
  161. package/dist/SuperDatePicker/SuperDatePicker.types.js +0 -1
  162. package/dist/SuperDatePicker/components/CommonPresetGroups.d.ts +0 -7
  163. package/dist/SuperDatePicker/components/CommonPresetGroups.js +0 -6
  164. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.d.ts +0 -10
  165. package/dist/SuperDatePicker/components/EndpointCalendarDropdown.js +0 -9
  166. package/dist/SuperDatePicker/components/EndpointDateInput.d.ts +0 -16
  167. package/dist/SuperDatePicker/components/EndpointDateInput.js +0 -26
  168. package/dist/SuperDatePicker/components/EndpointPopover.d.ts +0 -18
  169. package/dist/SuperDatePicker/components/EndpointPopover.js +0 -11
  170. package/dist/SuperDatePicker/components/QuickRangeDropdown.d.ts +0 -14
  171. package/dist/SuperDatePicker/components/QuickRangeDropdown.js +0 -19
  172. package/dist/SuperDatePicker/components/QuickRangePopover.d.ts +0 -18
  173. package/dist/SuperDatePicker/components/QuickRangePopover.js +0 -12
  174. package/dist/SuperDatePicker/components/index.d.ts +0 -6
  175. package/dist/SuperDatePicker/components/index.js +0 -6
  176. package/dist/SuperDatePicker/index.d.ts +0 -3
  177. package/dist/SuperDatePicker/index.js +0 -3
  178. package/dist/SuperDatePicker/useSuperDatePicker.d.ts +0 -32
  179. package/dist/SuperDatePicker/useSuperDatePicker.js +0 -125
@@ -1,548 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
22
- import { scaleLinear, scalePoint, scaleTime } from "d3-scale";
23
- import { forwardRef, useCallback, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, } from "react";
24
- import { useTheme } from "styled-components";
25
- import { ChartExportControl } from "../ChartPrimitives";
26
- import { DEFAULT_CHART_EXPORT_FORMATS, copyChartImage, downloadChartImage, useChartResponsiveSize, } from "../ChartUtils";
27
- import { buildAreaPath, buildLinePath, clamp, easeOutCubic, formatDefaultValue, getGradientStops, getPointKey, getSeriesKey, getSeriesLabelText, getValueDomain, measureSvgPath, mergeChartMargin, normalizeTickValue, parseLineChartXValue, resolveXAxisType, useThemeColor, useThemeColors, } from "./LineChart.lib";
28
- import { StyledArea, StyledAxisLine, StyledAxisText, StyledChartActions, StyledChartFrame, StyledChartScroller, StyledContainer, StyledEmptyState, StyledGridLine, StyledHoverTarget, StyledLegend, StyledLegendItem, StyledLegendLabel, StyledLegendLine, StyledLegendValue, StyledLine, StyledPoint, StyledSvg, StyledTooltip, StyledTooltipHeader, StyledTooltipLabel, StyledTooltipMeta, StyledTooltipSwatch, StyledValueLabel, } from "./LineChart.styled";
29
- const LineChartInner = (_a, ref) => {
30
- var _b, _c, _d;
31
- var { data, series, seriesLabel = "Series", width, height, responsive = false, aspectRatio, minWidth = 240, minHeight = 200, margin, xAxisType = "auto", curve = "monotone", lineColor, colors, colorGradient, lineWidth = 2.5, lineOpacity = 1, lineDasharray, showArea = false, areaColor, areaOpacity = 0.14, showPoints = false, pointRadius = 3, activePointRadius = 4, pointColor, pointBorderColor, pointBorderWidth = 1.5, pointOpacity = 1, yMin, yMax, xTickCount = 6, yTickCount = 5, showGridLines = true, showAxisLines = true, showXAxisLabels = true, showYAxisLabels = true, showLegend = false, showLabels = false, emptyLabel = "No data", ariaLabel = "Line chart", animateOnRender = false, animationDuration = 720, showExportButton = false, exportFileName = "line-chart", exportFormats = DEFAULT_CHART_EXPORT_FORMATS, exportScale = 2, exportBackgroundColor, showTooltips = false, valueFormatter, xValueFormatter, xTickFormatter, yTickFormatter, labelFormatter, tooltipFormatter, onPointClick, className } = _a, props = __rest(_a, ["data", "series", "seriesLabel", "width", "height", "responsive", "aspectRatio", "minWidth", "minHeight", "margin", "xAxisType", "curve", "lineColor", "colors", "colorGradient", "lineWidth", "lineOpacity", "lineDasharray", "showArea", "areaColor", "areaOpacity", "showPoints", "pointRadius", "activePointRadius", "pointColor", "pointBorderColor", "pointBorderWidth", "pointOpacity", "yMin", "yMax", "xTickCount", "yTickCount", "showGridLines", "showAxisLines", "showXAxisLabels", "showYAxisLabels", "showLegend", "showLabels", "emptyLabel", "ariaLabel", "animateOnRender", "animationDuration", "showExportButton", "exportFileName", "exportFormats", "exportScale", "exportBackgroundColor", "showTooltips", "valueFormatter", "xValueFormatter", "xTickFormatter", "yTickFormatter", "labelFormatter", "tooltipFormatter", "onPointClick", "className"]);
32
- const descriptionId = useId();
33
- const gradientBaseId = useId();
34
- const theme = useTheme();
35
- const containerRef = useRef(null);
36
- const chartSizeRef = useRef(null);
37
- const chartFrameRef = useRef(null);
38
- const svgRef = useRef(null);
39
- const tooltipRef = useRef(null);
40
- const linePathRefs = useRef({});
41
- const [activePointKey, setActivePointKey] = useState(null);
42
- const [activeSeriesKey, setActiveSeriesKey] = useState(null);
43
- const [activeTooltip, setActiveTooltip] = useState(null);
44
- const [tooltipSize, setTooltipSize] = useState({ width: 0, height: 0 });
45
- const [animationProgress, setAnimationProgress] = useState(animateOnRender ? 0 : 1);
46
- const [lineLengths, setLineLengths] = useState({});
47
- const themeLineColor = useThemeColor(lineColor);
48
- const themeColors = useThemeColors(colors);
49
- const resolvedMargin = mergeChartMargin(margin, showXAxisLabels, showYAxisLabels, showLabels);
50
- const chartSize = useChartResponsiveSize(chartSizeRef, {
51
- width,
52
- height,
53
- responsive,
54
- aspectRatio,
55
- defaultWidth: 720,
56
- defaultHeight: 320,
57
- minWidth: Math.max(minWidth, 1),
58
- minHeight: Math.max(minHeight, 1),
59
- });
60
- const safeWidth = chartSize.width;
61
- const safeHeight = chartSize.height;
62
- const plotWidth = Math.max(safeWidth - resolvedMargin.left - resolvedMargin.right, 1);
63
- const plotHeight = Math.max(safeHeight - resolvedMargin.top - resolvedMargin.bottom, 1);
64
- const resolvedGlobalLineWidth = Math.max(lineWidth, 1);
65
- const resolvedGlobalLineOpacity = clamp(lineOpacity, 0, 1);
66
- const resolvedGlobalAreaOpacity = clamp(areaOpacity, 0, 1);
67
- const resolvedGlobalPointRadius = Math.max(pointRadius, 0);
68
- const resolvedGlobalActivePointRadius = Math.max(activePointRadius, resolvedGlobalPointRadius);
69
- const resolvedPointOpacity = clamp(pointOpacity, 0, 1);
70
- const resolvedExportBackgroundColor = exportBackgroundColor !== null && exportBackgroundColor !== void 0 ? exportBackgroundColor : theme.palette.background.paper;
71
- useImperativeHandle(ref, () => ({
72
- getSvgElement: () => svgRef.current,
73
- downloadImage: (request) => __awaiter(void 0, void 0, void 0, function* () {
74
- var _a, _b, _c, _d;
75
- yield downloadChartImage({
76
- rootElement: containerRef.current,
77
- svg: svgRef.current,
78
- format: (_a = request === null || request === void 0 ? void 0 : request.format) !== null && _a !== void 0 ? _a : "svg",
79
- fileName: (_b = request === null || request === void 0 ? void 0 : request.fileName) !== null && _b !== void 0 ? _b : exportFileName,
80
- scale: (_c = request === null || request === void 0 ? void 0 : request.scale) !== null && _c !== void 0 ? _c : exportScale,
81
- backgroundColor: (_d = request === null || request === void 0 ? void 0 : request.backgroundColor) !== null && _d !== void 0 ? _d : resolvedExportBackgroundColor,
82
- });
83
- }),
84
- copyImage: (request) => __awaiter(void 0, void 0, void 0, function* () {
85
- var _a, _b, _c;
86
- return copyChartImage({
87
- rootElement: containerRef.current,
88
- svg: svgRef.current,
89
- format: (_a = request === null || request === void 0 ? void 0 : request.format) !== null && _a !== void 0 ? _a : "png",
90
- scale: (_b = request === null || request === void 0 ? void 0 : request.scale) !== null && _b !== void 0 ? _b : exportScale,
91
- backgroundColor: (_c = request === null || request === void 0 ? void 0 : request.backgroundColor) !== null && _c !== void 0 ? _c : resolvedExportBackgroundColor,
92
- });
93
- }),
94
- }), [exportFileName, exportScale, resolvedExportBackgroundColor]);
95
- const isMultiSeries = ((_b = series === null || series === void 0 ? void 0 : series.length) !== null && _b !== void 0 ? _b : 0) > 0;
96
- const normalizedInputSeries = useMemo(() => {
97
- if (series === null || series === void 0 ? void 0 : series.length) {
98
- return series.map((seriesItem, seriesIndex) => {
99
- const fallbackLabel = `Series ${seriesIndex + 1}`;
100
- return {
101
- key: getSeriesKey(seriesItem, seriesIndex),
102
- label: seriesItem.label,
103
- labelText: getSeriesLabelText(seriesItem.label, fallbackLabel),
104
- sourceSeries: seriesItem,
105
- color: seriesItem.color,
106
- colorGradient: seriesItem.colorGradient,
107
- lineDasharray: seriesItem.lineDasharray,
108
- lineWidth: seriesItem.lineWidth,
109
- lineOpacity: seriesItem.lineOpacity,
110
- showArea: seriesItem.showArea,
111
- areaColor: seriesItem.areaColor,
112
- areaOpacity: seriesItem.areaOpacity,
113
- showPoints: seriesItem.showPoints,
114
- pointColor: seriesItem.pointColor,
115
- pointRadius: seriesItem.pointRadius,
116
- activePointRadius: seriesItem.activePointRadius,
117
- data: seriesItem.data,
118
- };
119
- });
120
- }
121
- if (data === null || data === void 0 ? void 0 : data.length) {
122
- return [
123
- {
124
- key: "series-0",
125
- label: seriesLabel,
126
- labelText: getSeriesLabelText(seriesLabel, "Series"),
127
- data,
128
- },
129
- ];
130
- }
131
- return [];
132
- }, [data, series, seriesLabel]);
133
- const parsedSeriesInput = useMemo(() => {
134
- const seriesEntries = normalizedInputSeries.map((inputSeries, seriesIndex) => {
135
- const parsedPoints = inputSeries.data
136
- .map((datum, pointIndex) => {
137
- const parsedX = parseLineChartXValue(datum.x);
138
- if (parsedX == null || !Number.isFinite(datum.y))
139
- return null;
140
- return Object.assign(Object.assign({}, datum), { key: `${String(inputSeries.key)}-${getPointKey(datum, pointIndex)}`, index: pointIndex, parsedX, xType: "point", seriesKey: inputSeries.key, seriesIndex, seriesLabel: inputSeries.label, seriesLabelText: inputSeries.labelText, seriesColor: "" });
141
- })
142
- .filter(Boolean);
143
- return Object.assign(Object.assign({}, inputSeries), { points: parsedPoints });
144
- });
145
- const allPoints = seriesEntries.flatMap((entry) => entry.points);
146
- return {
147
- resolvedXAxisType: resolveXAxisType(allPoints, xAxisType),
148
- seriesEntries,
149
- };
150
- }, [normalizedInputSeries, xAxisType]);
151
- const resolvedSeries = useMemo(() => {
152
- return parsedSeriesInput.seriesEntries
153
- .map((seriesEntry, seriesIndex) => {
154
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
155
- const resolvedColor = (_a = seriesEntry.color) !== null && _a !== void 0 ? _a : (normalizedInputSeries.length === 1
156
- ? themeLineColor
157
- : themeColors[seriesIndex % themeColors.length]);
158
- const resolvedGradientStops = getGradientStops((_b = seriesEntry.colorGradient) !== null && _b !== void 0 ? _b : (normalizedInputSeries.length === 1 ? colorGradient : undefined));
159
- const resolvedPointRadius = Math.max((_c = seriesEntry.pointRadius) !== null && _c !== void 0 ? _c : resolvedGlobalPointRadius, 0);
160
- const resolvedActivePointRadius = Math.max((_d = seriesEntry.activePointRadius) !== null && _d !== void 0 ? _d : resolvedGlobalActivePointRadius, resolvedPointRadius);
161
- const points = seriesEntry.points
162
- .map((point) => (Object.assign(Object.assign({}, point), { xType: parsedSeriesInput.resolvedXAxisType, seriesColor: resolvedColor })))
163
- .sort((left, right) => {
164
- if (parsedSeriesInput.resolvedXAxisType === "point") {
165
- return left.index - right.index;
166
- }
167
- const leftValue = left.parsedX instanceof Date
168
- ? left.parsedX.getTime()
169
- : Number(left.parsedX);
170
- const rightValue = right.parsedX instanceof Date
171
- ? right.parsedX.getTime()
172
- : Number(right.parsedX);
173
- return leftValue - rightValue;
174
- });
175
- return {
176
- key: seriesEntry.key,
177
- label: seriesEntry.label,
178
- labelText: seriesEntry.labelText,
179
- color: resolvedColor,
180
- gradientStops: resolvedGradientStops,
181
- lineDasharray: (_e = seriesEntry.lineDasharray) !== null && _e !== void 0 ? _e : lineDasharray,
182
- lineWidth: Math.max((_f = seriesEntry.lineWidth) !== null && _f !== void 0 ? _f : resolvedGlobalLineWidth, 1),
183
- lineOpacity: clamp((_g = seriesEntry.lineOpacity) !== null && _g !== void 0 ? _g : resolvedGlobalLineOpacity, 0, 1),
184
- showArea: (_h = seriesEntry.showArea) !== null && _h !== void 0 ? _h : showArea,
185
- areaColor: (_k = (_j = seriesEntry.areaColor) !== null && _j !== void 0 ? _j : areaColor) !== null && _k !== void 0 ? _k : resolvedColor,
186
- areaOpacity: clamp((_l = seriesEntry.areaOpacity) !== null && _l !== void 0 ? _l : resolvedGlobalAreaOpacity, 0, 1),
187
- showPoints: (_m = seriesEntry.showPoints) !== null && _m !== void 0 ? _m : showPoints,
188
- pointColor: (_p = (_o = seriesEntry.pointColor) !== null && _o !== void 0 ? _o : pointColor) !== null && _p !== void 0 ? _p : resolvedColor,
189
- pointRadius: resolvedPointRadius,
190
- activePointRadius: resolvedActivePointRadius,
191
- sourceSeries: seriesEntry.sourceSeries,
192
- points,
193
- };
194
- })
195
- .filter((seriesEntry) => seriesEntry.points.length > 0);
196
- }, [
197
- areaColor,
198
- colorGradient,
199
- lineDasharray,
200
- normalizedInputSeries.length,
201
- parsedSeriesInput.resolvedXAxisType,
202
- parsedSeriesInput.seriesEntries,
203
- pointColor,
204
- resolvedGlobalActivePointRadius,
205
- resolvedGlobalAreaOpacity,
206
- resolvedGlobalLineOpacity,
207
- resolvedGlobalLineWidth,
208
- resolvedGlobalPointRadius,
209
- showArea,
210
- showPoints,
211
- themeColors,
212
- themeLineColor,
213
- ]);
214
- const allPoints = useMemo(() => resolvedSeries.flatMap((seriesEntry) => seriesEntry.points), [resolvedSeries]);
215
- const resolvedXAxisType = parsedSeriesInput.resolvedXAxisType;
216
- const resolvedPointBorderColor = pointBorderColor !== null && pointBorderColor !== void 0 ? pointBorderColor : theme.palette.background.paper;
217
- const timeScale = useMemo(() => {
218
- if (resolvedXAxisType !== "time")
219
- return null;
220
- const timeValues = allPoints
221
- .map((point) => point.parsedX instanceof Date ? point.parsedX.getTime() : null)
222
- .filter((value) => value != null);
223
- const min = Math.min(...timeValues);
224
- const max = Math.max(...timeValues);
225
- const scale = scaleTime()
226
- .domain([new Date(min), new Date(max === min ? min + 1 : max)])
227
- .range([0, plotWidth]);
228
- scale.nice(Math.max(xTickCount, 2));
229
- return scale;
230
- }, [allPoints, plotWidth, resolvedXAxisType, xTickCount]);
231
- const linearScale = useMemo(() => {
232
- if (resolvedXAxisType !== "linear")
233
- return null;
234
- const numericValues = allPoints.map((point) => Number(point.parsedX));
235
- const min = Math.min(...numericValues);
236
- const max = Math.max(...numericValues);
237
- const scale = scaleLinear()
238
- .domain([min, max === min ? min + 1 : max])
239
- .range([0, plotWidth]);
240
- scale.nice(Math.max(xTickCount, 2));
241
- return scale;
242
- }, [allPoints, plotWidth, resolvedXAxisType, xTickCount]);
243
- const pointScale = useMemo(() => {
244
- if (resolvedXAxisType !== "point")
245
- return null;
246
- const domain = Array.from(new Set(allPoints.map((point) => String(point.parsedX))));
247
- return scalePoint()
248
- .domain(domain)
249
- .range([0, plotWidth])
250
- .padding(0.4);
251
- }, [allPoints, plotWidth, resolvedXAxisType]);
252
- const yScale = useMemo(() => {
253
- const scale = scaleLinear()
254
- .domain(getValueDomain(allPoints.map((point) => point.y), yMin, yMax))
255
- .range([plotHeight, 0]);
256
- if (yMin == null || yMax == null) {
257
- scale.nice(Math.max(yTickCount, 2));
258
- }
259
- return scale;
260
- }, [allPoints, plotHeight, yMax, yMin, yTickCount]);
261
- const getPointX = useCallback((point) => {
262
- var _a, _b, _c;
263
- if (resolvedXAxisType === "time") {
264
- return (_a = timeScale === null || timeScale === void 0 ? void 0 : timeScale(point.parsedX)) !== null && _a !== void 0 ? _a : 0;
265
- }
266
- if (resolvedXAxisType === "linear") {
267
- return (_b = linearScale === null || linearScale === void 0 ? void 0 : linearScale(Number(point.parsedX))) !== null && _b !== void 0 ? _b : 0;
268
- }
269
- return (_c = pointScale === null || pointScale === void 0 ? void 0 : pointScale(String(point.parsedX))) !== null && _c !== void 0 ? _c : 0;
270
- }, [linearScale, pointScale, resolvedXAxisType, timeScale]);
271
- const getPointY = useCallback((point) => yScale(point.y), [yScale]);
272
- const renderedSeries = useMemo(() => resolvedSeries.map((seriesEntry, seriesIndex) => (Object.assign(Object.assign({}, seriesEntry), { gradientId: `${gradientBaseId}-${seriesIndex}`, linePath: buildLinePath(seriesEntry.points, getPointX, getPointY, curve), areaPath: seriesEntry.showArea
273
- ? buildAreaPath(seriesEntry.points, getPointX, getPointY, plotHeight, curve)
274
- : null }))), [curve, getPointX, gradientBaseId, plotHeight, resolvedSeries]);
275
- const renderedSeriesKey = useMemo(() => renderedSeries
276
- .map((seriesEntry) => {
277
- var _a, _b;
278
- return `${String(seriesEntry.key)}:${(_a = seriesEntry.linePath) !== null && _a !== void 0 ? _a : ""}:${(_b = seriesEntry.areaPath) !== null && _b !== void 0 ? _b : ""}`;
279
- })
280
- .join("|"), [renderedSeries]);
281
- useLayoutEffect(() => {
282
- const nextLineLengths = {};
283
- renderedSeries.forEach((seriesEntry) => {
284
- var _a;
285
- nextLineLengths[String(seriesEntry.key)] = measureSvgPath((_a = linePathRefs.current[String(seriesEntry.key)]) !== null && _a !== void 0 ? _a : null);
286
- });
287
- setLineLengths((currentLineLengths) => {
288
- const currentKeys = Object.keys(currentLineLengths);
289
- const nextKeys = Object.keys(nextLineLengths);
290
- if (currentKeys.length !== nextKeys.length) {
291
- return nextLineLengths;
292
- }
293
- for (const key of nextKeys) {
294
- if (currentLineLengths[key] !== nextLineLengths[key]) {
295
- return nextLineLengths;
296
- }
297
- }
298
- return currentLineLengths;
299
- });
300
- }, [renderedSeries, renderedSeriesKey]);
301
- useLayoutEffect(() => {
302
- var _a;
303
- if (!animateOnRender ||
304
- renderedSeries.every((seriesEntry) => !seriesEntry.linePath)) {
305
- setAnimationProgress(1);
306
- return;
307
- }
308
- const prefersReducedMotion = typeof window !== "undefined" &&
309
- ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, "(prefers-reduced-motion: reduce)").matches);
310
- if (prefersReducedMotion) {
311
- setAnimationProgress(1);
312
- return;
313
- }
314
- let animationFrame = 0;
315
- let startTime = null;
316
- const safeDuration = Math.max(animationDuration, 0);
317
- setAnimationProgress(0);
318
- const runAnimation = (timestamp) => {
319
- if (startTime == null)
320
- startTime = timestamp;
321
- const elapsed = timestamp - startTime;
322
- const progress = safeDuration === 0
323
- ? 1
324
- : easeOutCubic(clamp(elapsed / safeDuration, 0, 1));
325
- setAnimationProgress(progress);
326
- if (progress < 1) {
327
- animationFrame = window.requestAnimationFrame(runAnimation);
328
- }
329
- };
330
- animationFrame = window.requestAnimationFrame(runAnimation);
331
- return () => {
332
- window.cancelAnimationFrame(animationFrame);
333
- };
334
- }, [animateOnRender, animationDuration, renderedSeriesKey]);
335
- const xTicks = useMemo(() => {
336
- var _a;
337
- if (resolvedXAxisType === "time" && timeScale) {
338
- return timeScale.ticks(Math.max(xTickCount, 2));
339
- }
340
- if (resolvedXAxisType === "linear" && linearScale) {
341
- return linearScale
342
- .ticks(Math.max(xTickCount, 2))
343
- .map((tick) => normalizeTickValue(tick));
344
- }
345
- const domain = (_a = pointScale === null || pointScale === void 0 ? void 0 : pointScale.domain()) !== null && _a !== void 0 ? _a : [];
346
- if (domain.length <= Math.max(xTickCount, 2))
347
- return domain;
348
- const step = Math.ceil(domain.length / Math.max(xTickCount, 2));
349
- return domain.filter((_, index) => index % step === 0);
350
- }, [linearScale, pointScale, resolvedXAxisType, timeScale, xTickCount]);
351
- const yTicks = useMemo(() => Array.from(new Set(yScale
352
- .ticks(Math.max(yTickCount, 2))
353
- .map((tick) => normalizeTickValue(tick)))), [yScale, yTickCount]);
354
- const formatValue = (datum, sourceSeries) => {
355
- var _a;
356
- return (_a = valueFormatter === null || valueFormatter === void 0 ? void 0 : valueFormatter(datum.y, datum, sourceSeries)) !== null && _a !== void 0 ? _a : formatDefaultValue(datum.y);
357
- };
358
- const formatXValue = (datum, sourceSeries) => {
359
- var _a;
360
- return (_a = xValueFormatter === null || xValueFormatter === void 0 ? void 0 : xValueFormatter(datum.x, datum, sourceSeries)) !== null && _a !== void 0 ? _a : (datum.x instanceof Date ? datum.x.toLocaleDateString() : String(datum.x));
361
- };
362
- const formatXTick = (value) => {
363
- var _a;
364
- return (_a = xTickFormatter === null || xTickFormatter === void 0 ? void 0 : xTickFormatter(value)) !== null && _a !== void 0 ? _a : (value instanceof Date
365
- ? new Intl.DateTimeFormat(undefined, {
366
- month: "short",
367
- day: "numeric",
368
- }).format(value)
369
- : String(value));
370
- };
371
- const formatYTick = (value) => { var _a; return (_a = yTickFormatter === null || yTickFormatter === void 0 ? void 0 : yTickFormatter(value)) !== null && _a !== void 0 ? _a : formatDefaultValue(value); };
372
- const findNearestPoint = (clientX, clientY) => {
373
- if (!chartFrameRef.current)
374
- return null;
375
- const chartRect = chartFrameRef.current.getBoundingClientRect();
376
- const localX = clamp(clientX - chartRect.left - resolvedMargin.left, 0, plotWidth);
377
- const localY = clamp(clientY - chartRect.top - resolvedMargin.top, 0, plotHeight);
378
- let nearestPoint = null;
379
- let nearestDistance = Number.POSITIVE_INFINITY;
380
- for (const point of allPoints) {
381
- const pointX = getPointX(point);
382
- const pointY = getPointY(point);
383
- const dx = pointX - localX;
384
- const dy = pointY - localY;
385
- const distance = dx * dx + dy * dy * 0.18;
386
- if (distance < nearestDistance) {
387
- nearestDistance = distance;
388
- nearestPoint = point;
389
- }
390
- }
391
- return nearestPoint;
392
- };
393
- const updateActivePointFromEvent = (event, triggerTooltip) => {
394
- const nearestPoint = findNearestPoint(event.clientX, event.clientY);
395
- if (!nearestPoint)
396
- return;
397
- setActivePointKey(nearestPoint.key);
398
- if (!triggerTooltip)
399
- return;
400
- setActiveTooltip({
401
- pointKey: nearestPoint.key,
402
- x: resolvedMargin.left + getPointX(nearestPoint),
403
- y: resolvedMargin.top + getPointY(nearestPoint),
404
- });
405
- };
406
- const activePoint = (showTooltips || showPoints || onPointClick) && activePointKey != null
407
- ? allPoints.find((point) => point.key === activePointKey)
408
- : null;
409
- const highlightedSeriesKey = (_c = activeSeriesKey !== null && activeSeriesKey !== void 0 ? activeSeriesKey : activePoint === null || activePoint === void 0 ? void 0 : activePoint.seriesKey) !== null && _c !== void 0 ? _c : null;
410
- const activeSeries = activePoint
411
- ? renderedSeries.find((seriesEntry) => seriesEntry.key === activePoint.seriesKey)
412
- : null;
413
- const tooltipStyle = useMemo(() => {
414
- if (!activeTooltip ||
415
- !containerRef.current ||
416
- !chartFrameRef.current ||
417
- !activePoint) {
418
- return null;
419
- }
420
- const containerRect = containerRef.current.getBoundingClientRect();
421
- const chartRect = chartFrameRef.current.getBoundingClientRect();
422
- const chartLeft = chartRect.left - containerRect.left;
423
- const chartTop = chartRect.top - containerRect.top;
424
- const minLeft = chartLeft + 8;
425
- const maxLeft = chartLeft + chartRect.width - tooltipSize.width - 8;
426
- const minTop = chartTop + 8;
427
- const maxTop = chartTop + chartRect.height - tooltipSize.height - 8;
428
- return {
429
- left: clamp(activeTooltip.x + 14, minLeft, Math.max(minLeft, maxLeft)),
430
- top: clamp(activeTooltip.y - tooltipSize.height / 2, minTop, Math.max(minTop, maxTop)),
431
- };
432
- }, [activePoint, activeTooltip, tooltipSize.height, tooltipSize.width]);
433
- useEffect(() => {
434
- if (!activePoint || !tooltipRef.current) {
435
- setTooltipSize({ width: 0, height: 0 });
436
- return;
437
- }
438
- setTooltipSize({
439
- width: tooltipRef.current.offsetWidth,
440
- height: tooltipRef.current.offsetHeight,
441
- });
442
- }, [activePoint]);
443
- const description = allPoints
444
- .map((point) => `${point.seriesLabelText}, ${formatXValue(point, activeSeries === null || activeSeries === void 0 ? void 0 : activeSeries.sourceSeries)}: ${formatDefaultValue(point.y)}`)
445
- .join(", ");
446
- const shouldAnimateStroke = animateOnRender && animationProgress < 1;
447
- const shouldShowDataLabels = showLabels && allPoints.length <= 24;
448
- return (_jsxs(StyledContainer, Object.assign({ ref: containerRef, className: className, "$fillAvailableWidth": chartSize.fillAvailableWidth }, props, { children: [_jsx(StyledChartScroller, { ref: chartSizeRef, "$width": chartSize.widthStyle, "$height": chartSize.heightStyle, children: allPoints.length === 0 ? (_jsx(StyledEmptyState, { "$width": safeWidth, "$height": safeHeight, children: emptyLabel })) : (_jsxs(StyledChartFrame, { ref: chartFrameRef, children: [showExportButton && exportFormats.length > 0 && (_jsx(StyledChartActions, { "data-chart-export-ignore": "true", children: _jsx(ChartExportControl, { rootRef: containerRef, svgRef: svgRef, fileName: exportFileName, formats: exportFormats, scale: exportScale, backgroundColor: resolvedExportBackgroundColor }) })), _jsxs(StyledSvg, { ref: svgRef, width: safeWidth, height: safeHeight, viewBox: `0 0 ${safeWidth} ${safeHeight}`, role: "img", "aria-label": ariaLabel, "aria-describedby": descriptionId, children: [_jsx("desc", { id: descriptionId, children: description }), _jsx("defs", { children: renderedSeries
449
- .filter((seriesEntry) => { var _a; return (_a = seriesEntry.gradientStops) === null || _a === void 0 ? void 0 : _a.length; })
450
- .map((seriesEntry) => {
451
- var _a;
452
- return (_jsx("linearGradient", { id: seriesEntry.gradientId, x1: "0%", y1: "0%", x2: "100%", y2: "0%", children: ((_a = seriesEntry.gradientStops) !== null && _a !== void 0 ? _a : []).map((stop, index) => {
453
- var _a, _b;
454
- return (_jsx("stop", { offset: `${((_a = seriesEntry.gradientStops) !== null && _a !== void 0 ? _a : []).length === 1
455
- ? 100
456
- : (index /
457
- (((_b = seriesEntry.gradientStops) !== null && _b !== void 0 ? _b : []).length -
458
- 1)) *
459
- 100}%`, stopColor: stop }, `${stop}-${index}`));
460
- }) }, seriesEntry.gradientId));
461
- }) }), showGridLines &&
462
- yTicks.map((tick) => (_jsx(StyledGridLine, { x1: resolvedMargin.left, x2: resolvedMargin.left + plotWidth, y1: resolvedMargin.top + yScale(tick), y2: resolvedMargin.top + yScale(tick) }, `grid-y-${tick}`))), showAxisLines && (_jsxs(_Fragment, { children: [_jsx(StyledAxisLine, { x1: resolvedMargin.left, x2: resolvedMargin.left, y1: resolvedMargin.top, y2: resolvedMargin.top + plotHeight }), _jsx(StyledAxisLine, { x1: resolvedMargin.left, x2: resolvedMargin.left + plotWidth, y1: resolvedMargin.top + plotHeight, y2: resolvedMargin.top + plotHeight })] })), showYAxisLabels &&
463
- yTicks.map((tick) => (_jsx(StyledAxisText, { x: resolvedMargin.left - 10, y: resolvedMargin.top + yScale(tick), textAnchor: "end", dominantBaseline: "middle", children: formatYTick(tick) }, `tick-y-${tick}`))), showXAxisLabels &&
464
- xTicks.map((tick, index) => {
465
- var _a, _b, _c;
466
- const x = resolvedXAxisType === "time"
467
- ? ((_a = timeScale === null || timeScale === void 0 ? void 0 : timeScale(tick)) !== null && _a !== void 0 ? _a : 0)
468
- : resolvedXAxisType === "linear"
469
- ? ((_b = linearScale === null || linearScale === void 0 ? void 0 : linearScale(tick)) !== null && _b !== void 0 ? _b : 0)
470
- : ((_c = pointScale === null || pointScale === void 0 ? void 0 : pointScale(String(tick))) !== null && _c !== void 0 ? _c : 0);
471
- return (_jsx(StyledAxisText, { x: resolvedMargin.left + x, y: resolvedMargin.top + plotHeight + 20, textAnchor: "middle", children: formatXTick(tick) }, `tick-x-${index}`));
472
- }), _jsxs("g", { transform: `translate(${resolvedMargin.left}, ${resolvedMargin.top})`, children: [_jsx(StyledHoverTarget, { x: 0, y: 0, width: plotWidth, height: plotHeight, onMouseEnter: (event) => {
473
- if (!showTooltips && !showPoints && !onPointClick)
474
- return;
475
- updateActivePointFromEvent(event, showTooltips);
476
- }, onMouseMove: (event) => {
477
- if (!showTooltips && !showPoints && !onPointClick)
478
- return;
479
- updateActivePointFromEvent(event, showTooltips);
480
- }, onMouseLeave: () => {
481
- setActivePointKey(null);
482
- setActiveTooltip(null);
483
- }, onClick: (event) => {
484
- if (!onPointClick)
485
- return;
486
- const nearestPoint = findNearestPoint(event.clientX, event.clientY);
487
- const nearestSeries = nearestPoint
488
- ? renderedSeries.find((seriesEntry) => seriesEntry.key === nearestPoint.seriesKey)
489
- : null;
490
- if (nearestPoint) {
491
- onPointClick(event, nearestPoint, nearestSeries === null || nearestSeries === void 0 ? void 0 : nearestSeries.sourceSeries);
492
- }
493
- } }), renderedSeries.map((seriesEntry) => {
494
- var _a, _b;
495
- const gradientReference = ((_a = seriesEntry.gradientStops) === null || _a === void 0 ? void 0 : _a.length)
496
- ? `url(#${seriesEntry.gradientId})`
497
- : seriesEntry.color;
498
- const lineLength = (_b = lineLengths[String(seriesEntry.key)]) !== null && _b !== void 0 ? _b : 0;
499
- const isSeriesActive = highlightedSeriesKey === seriesEntry.key;
500
- const isSeriesDimmed = highlightedSeriesKey != null && !isSeriesActive;
501
- return (_jsxs("g", { children: [seriesEntry.showArea && seriesEntry.areaPath && (_jsx(StyledArea, { d: seriesEntry.areaPath, fill: gradientReference !== null && gradientReference !== void 0 ? gradientReference : seriesEntry.areaColor, fillOpacity: seriesEntry.areaOpacity *
502
- animationProgress *
503
- (isSeriesDimmed ? 0.28 : isSeriesActive ? 1.08 : 1), style: {
504
- filter: isSeriesActive
505
- ? "brightness(1.08) saturate(1.06)"
506
- : undefined,
507
- opacity: isSeriesDimmed ? 0.7 : 1,
508
- } })), seriesEntry.linePath && (_jsx(StyledLine, { "$active": isSeriesActive, "$dimmed": isSeriesDimmed, ref: (node) => {
509
- linePathRefs.current[String(seriesEntry.key)] =
510
- node;
511
- }, d: seriesEntry.linePath, stroke: gradientReference, strokeWidth: isSeriesActive
512
- ? seriesEntry.lineWidth + 0.8
513
- : seriesEntry.lineWidth, strokeOpacity: seriesEntry.lineOpacity, strokeDasharray: shouldAnimateStroke && lineLength > 0
514
- ? `${lineLength} ${lineLength}`
515
- : seriesEntry.lineDasharray, strokeDashoffset: shouldAnimateStroke && lineLength > 0
516
- ? lineLength * (1 - animationProgress)
517
- : 0 }))] }, seriesEntry.key));
518
- }), (showPoints || activePoint != null) &&
519
- renderedSeries.map((seriesEntry) => seriesEntry.points.map((point) => {
520
- var _a;
521
- const isActive = activePointKey === point.key;
522
- const shouldRender = seriesEntry.showPoints || isActive;
523
- if (!shouldRender)
524
- return null;
525
- return (_jsx(StyledPoint, { "$active": isActive, cx: getPointX(point), cy: getPointY(point), r: isActive
526
- ? seriesEntry.activePointRadius
527
- : seriesEntry.pointRadius, fill: (_a = point.color) !== null && _a !== void 0 ? _a : seriesEntry.pointColor, fillOpacity: resolvedPointOpacity, stroke: resolvedPointBorderColor, strokeWidth: pointBorderWidth, tabIndex: 0, "aria-label": `${point.seriesLabelText}, ${formatXValue(point, seriesEntry.sourceSeries)}: ${formatDefaultValue(point.y)}`, onFocus: () => setActivePointKey(point.key), onBlur: () => setActivePointKey(null), onMouseEnter: () => setActivePointKey(point.key), onMouseLeave: () => {
528
- if (!showTooltips)
529
- setActivePointKey(null);
530
- }, onClick: (event) => onPointClick === null || onPointClick === void 0 ? void 0 : onPointClick(event, point, seriesEntry.sourceSeries), onKeyDown: (event) => {
531
- if (event.key !== "Enter" && event.key !== " ")
532
- return;
533
- event.preventDefault();
534
- onPointClick === null || onPointClick === void 0 ? void 0 : onPointClick(event, point, seriesEntry.sourceSeries);
535
- } }, point.key));
536
- })), shouldShowDataLabels &&
537
- renderedSeries.map((seriesEntry) => seriesEntry.points.map((point) => {
538
- var _a;
539
- return (_jsx(StyledValueLabel, { x: getPointX(point), y: getPointY(point) - 10, textAnchor: "middle", children: (_a = labelFormatter === null || labelFormatter === void 0 ? void 0 : labelFormatter(point, point.index, seriesEntry.sourceSeries)) !== null && _a !== void 0 ? _a : formatValue(point, seriesEntry.sourceSeries) }, `label-${point.key}`));
540
- }))] })] })] })) }), activeTooltip && activePoint && activeSeries && tooltipStyle && (_jsx(StyledTooltip, { ref: tooltipRef, style: tooltipStyle, children: tooltipFormatter ? (tooltipFormatter(activePoint, activePoint.index, activeSeries.sourceSeries)) : (_jsxs(_Fragment, { children: [_jsxs(StyledTooltipHeader, { children: [_jsx(StyledTooltipSwatch, { "$color": (_d = activePoint.color) !== null && _d !== void 0 ? _d : activeSeries.pointColor }), _jsx(StyledTooltipLabel, { children: formatXValue(activePoint, activeSeries.sourceSeries) })] }), _jsxs(StyledTooltipMeta, { children: [_jsx("span", { children: activePoint.seriesLabel }), _jsx("span", { children: formatValue(activePoint, activeSeries.sourceSeries) })] })] })) })), showLegend && (_jsx(StyledLegend, { children: renderedSeries.map((seriesEntry) => {
541
- const latestPoint = seriesEntry.points[seriesEntry.points.length - 1];
542
- if (!latestPoint)
543
- return null;
544
- return (_jsxs(StyledLegendItem, { "$active": highlightedSeriesKey === seriesEntry.key, tabIndex: 0, onMouseEnter: () => setActiveSeriesKey(seriesEntry.key), onMouseLeave: () => setActiveSeriesKey(null), onFocus: () => setActiveSeriesKey(seriesEntry.key), onBlur: () => setActiveSeriesKey(null), children: [_jsx(StyledLegendLine, { "$color": seriesEntry.color }), _jsx(StyledLegendLabel, { children: seriesEntry.label }), _jsx(StyledLegendValue, { children: formatValue(latestPoint, seriesEntry.sourceSeries) })] }, `legend-${seriesEntry.key}`));
545
- }) }))] })));
546
- };
547
- export const LineChart = forwardRef(LineChartInner);
548
- export default LineChart;
@@ -1,24 +0,0 @@
1
- import { ReactNode } from "react";
2
- import { clamp, easeOutCubic, formatDefaultValue, getGradientColor, getGradientStops, mixColors } from "../ChartUtils";
3
- import { LineChartCurve, LineChartDatum, LineChartMargin, LineChartSeries, LineChartXAxisType, ResolvedLinePoint } from "./LineChart.types";
4
- export { clamp, easeOutCubic, formatDefaultValue, getGradientColor, getGradientStops, mixColors };
5
- export declare const getPointKey: (datum: LineChartDatum<unknown>, index: number) => string | number;
6
- export declare const getSeriesKey: (series: Pick<LineChartSeries<unknown>, "id" | "label">, index: number) => string | number;
7
- export declare const useThemeColor: (lineColor?: string) => string;
8
- export declare const useThemeColors: (colors?: string[]) => string[];
9
- export declare const getSeriesLabelText: (label: ReactNode, fallback: string) => string;
10
- export declare const parseLineChartXValue: (value: Date | number | string) => Date | number | string | null;
11
- export declare const resolveXAxisType: <TData>(points: ResolvedLinePoint<TData>[], xAxisType: LineChartXAxisType) => "time" | "linear" | "point";
12
- export declare const getDefaultMargin: (showXAxisLabels: boolean, showYAxisLabels: boolean, showLabels: boolean) => LineChartMargin;
13
- export declare const mergeChartMargin: (margin: Partial<LineChartMargin> | undefined, showXAxisLabels: boolean, showYAxisLabels: boolean, showLabels: boolean) => {
14
- top: number;
15
- right: number;
16
- bottom: number;
17
- left: number;
18
- };
19
- export declare const getValueDomain: (values: number[], minValue?: number, maxValue?: number) => [number, number];
20
- export declare const getCurveFactory: (curve: LineChartCurve) => import("d3-shape").CurveFactory;
21
- export declare const buildLinePath: <TData>(points: ResolvedLinePoint<TData>[], getX: (point: ResolvedLinePoint<TData>) => number, getY: (point: ResolvedLinePoint<TData>) => number, curve: LineChartCurve) => string | null;
22
- export declare const buildAreaPath: <TData>(points: ResolvedLinePoint<TData>[], getX: (point: ResolvedLinePoint<TData>) => number, getY: (point: ResolvedLinePoint<TData>) => number, y0: number, curve: LineChartCurve) => string | null;
23
- export declare const measureSvgPath: (path: SVGPathElement | null) => number;
24
- export declare const normalizeTickValue: (value: number) => number;