@monolith-forensics/monolith-ui 1.8.0 → 1.8.1-dev.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 (175) hide show
  1. package/dist/BarChart/BarChart.d.ts +3 -0
  2. package/dist/BarChart/BarChart.js +511 -0
  3. package/dist/BarChart/BarChart.lib.d.ts +31 -0
  4. package/dist/BarChart/BarChart.lib.js +136 -0
  5. package/dist/BarChart/BarChart.styled.d.ts +49 -0
  6. package/dist/BarChart/BarChart.styled.js +111 -0
  7. package/dist/BarChart/BarChart.types.d.ts +170 -0
  8. package/dist/BarChart/BarChart.types.js +1 -0
  9. package/dist/BarChart/index.d.ts +3 -0
  10. package/dist/BarChart/index.js +2 -0
  11. package/dist/Button/Button.js +9 -58
  12. package/dist/Calendar/Calendar.d.ts +3 -1
  13. package/dist/Calendar/Calendar.js +134 -33
  14. package/dist/Calendar/CalendarStyles.d.ts +3 -0
  15. package/dist/Calendar/CalendarStyles.js +92 -14
  16. package/dist/Calendar/calendarHelpers.d.ts +5 -1
  17. package/dist/Calendar/calendarHelpers.js +13 -5
  18. package/dist/ChartPrimitives/chartLegend.styled.d.ts +12 -0
  19. package/dist/ChartPrimitives/chartLegend.styled.js +52 -0
  20. package/dist/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
  21. package/dist/ChartPrimitives/chartTooltip.styled.js +61 -0
  22. package/dist/ChartPrimitives/index.d.ts +2 -0
  23. package/dist/ChartPrimitives/index.js +2 -0
  24. package/dist/ChartUtils/chartColors.d.ts +8 -0
  25. package/dist/ChartUtils/chartColors.js +65 -0
  26. package/dist/ChartUtils/chartMath.d.ts +3 -0
  27. package/dist/ChartUtils/chartMath.js +3 -0
  28. package/dist/ChartUtils/index.d.ts +2 -0
  29. package/dist/ChartUtils/index.js +2 -0
  30. package/dist/Charts/BarChart/BarChart.d.ts +5 -0
  31. package/dist/Charts/BarChart/BarChart.js +549 -0
  32. package/dist/Charts/BarChart/BarChart.lib.d.ts +31 -0
  33. package/dist/Charts/BarChart/BarChart.lib.js +136 -0
  34. package/dist/Charts/BarChart/BarChart.styled.d.ts +51 -0
  35. package/dist/Charts/BarChart/BarChart.styled.js +115 -0
  36. package/dist/Charts/BarChart/BarChart.types.d.ts +171 -0
  37. package/dist/Charts/BarChart/BarChart.types.js +1 -0
  38. package/dist/Charts/BarChart/index.d.ts +3 -0
  39. package/dist/Charts/BarChart/index.js +2 -0
  40. package/dist/Charts/ChartPrimitives/ChartExportControl.d.ts +11 -0
  41. package/dist/Charts/ChartPrimitives/ChartExportControl.js +29 -0
  42. package/dist/Charts/ChartPrimitives/chartActions.styled.d.ts +1 -0
  43. package/dist/Charts/ChartPrimitives/chartActions.styled.js +8 -0
  44. package/dist/Charts/ChartPrimitives/chartLegend.styled.d.ts +12 -0
  45. package/dist/Charts/ChartPrimitives/chartLegend.styled.js +52 -0
  46. package/dist/Charts/ChartPrimitives/chartTooltip.styled.d.ts +19 -0
  47. package/dist/Charts/ChartPrimitives/chartTooltip.styled.js +61 -0
  48. package/dist/Charts/ChartPrimitives/index.d.ts +4 -0
  49. package/dist/Charts/ChartPrimitives/index.js +4 -0
  50. package/dist/Charts/ChartUtils/chartColors.d.ts +8 -0
  51. package/dist/Charts/ChartUtils/chartColors.js +65 -0
  52. package/dist/Charts/ChartUtils/chartExport.d.ts +47 -0
  53. package/dist/Charts/ChartUtils/chartExport.js +311 -0
  54. package/dist/Charts/ChartUtils/chartMath.d.ts +3 -0
  55. package/dist/Charts/ChartUtils/chartMath.js +3 -0
  56. package/dist/Charts/ChartUtils/index.d.ts +3 -0
  57. package/dist/Charts/ChartUtils/index.js +3 -0
  58. package/dist/Charts/HeatMap/HeatMap.d.ts +5 -0
  59. package/dist/Charts/HeatMap/HeatMap.js +212 -0
  60. package/dist/Charts/HeatMap/HeatMap.lib.d.ts +30 -0
  61. package/dist/Charts/HeatMap/HeatMap.lib.js +115 -0
  62. package/dist/Charts/HeatMap/HeatMap.styled.d.ts +37 -0
  63. package/dist/Charts/HeatMap/HeatMap.styled.js +91 -0
  64. package/dist/Charts/HeatMap/HeatMap.types.d.ts +80 -0
  65. package/dist/Charts/HeatMap/HeatMap.types.js +1 -0
  66. package/dist/Charts/HeatMap/index.d.ts +3 -0
  67. package/dist/Charts/HeatMap/index.js +2 -0
  68. package/dist/Charts/LineChart/LineChart.d.ts +5 -0
  69. package/dist/Charts/LineChart/LineChart.js +529 -0
  70. package/dist/Charts/LineChart/LineChart.lib.d.ts +24 -0
  71. package/dist/Charts/LineChart/LineChart.lib.js +132 -0
  72. package/dist/Charts/LineChart/LineChart.styled.d.ts +59 -0
  73. package/dist/Charts/LineChart/LineChart.styled.js +147 -0
  74. package/dist/Charts/LineChart/LineChart.types.d.ts +193 -0
  75. package/dist/Charts/LineChart/LineChart.types.js +1 -0
  76. package/dist/Charts/LineChart/index.d.ts +3 -0
  77. package/dist/Charts/LineChart/index.js +2 -0
  78. package/dist/Charts/PieChart/PieChart.d.ts +4 -0
  79. package/dist/Charts/PieChart/PieChart.js +199 -0
  80. package/dist/Charts/PieChart/PieChart.lib.d.ts +5 -0
  81. package/dist/Charts/PieChart/PieChart.lib.js +19 -0
  82. package/dist/Charts/PieChart/PieChart.styled.d.ts +51 -0
  83. package/dist/Charts/PieChart/PieChart.styled.js +163 -0
  84. package/dist/Charts/PieChart/PieChart.types.d.ts +100 -0
  85. package/dist/Charts/PieChart/PieChart.types.js +1 -0
  86. package/dist/Charts/PieChart/index.d.ts +2 -0
  87. package/dist/Charts/PieChart/index.js +1 -0
  88. package/dist/Charts/index.d.ts +5 -0
  89. package/dist/Charts/index.js +4 -0
  90. package/dist/CheckBox/CheckBox.js +2 -16
  91. package/dist/DateInput/DateInput.js +198 -143
  92. package/dist/DropDownMenu/components/MenuComponent.js +2 -1
  93. package/dist/DropDownMenu/components/MenuItem.js +5 -14
  94. package/dist/DropDownMenu/components/MenuItemList.js +7 -24
  95. package/dist/DropDownMenu/components/StyledFloatContainer.js +1 -1
  96. package/dist/FieldLabel/FieldLabel.js +4 -12
  97. package/dist/FileInputField/FileInputField.js +4 -23
  98. package/dist/FormSection/FormSection.js +5 -25
  99. package/dist/HeatMap/HeatMap.d.ts +3 -0
  100. package/dist/HeatMap/HeatMap.js +174 -0
  101. package/dist/HeatMap/HeatMap.lib.d.ts +30 -0
  102. package/dist/HeatMap/HeatMap.lib.js +115 -0
  103. package/dist/HeatMap/HeatMap.styled.d.ts +34 -0
  104. package/dist/HeatMap/HeatMap.styled.js +83 -0
  105. package/dist/HeatMap/HeatMap.types.d.ts +79 -0
  106. package/dist/HeatMap/HeatMap.types.js +1 -0
  107. package/dist/HeatMap/index.d.ts +3 -0
  108. package/dist/HeatMap/index.js +2 -0
  109. package/dist/IconButton/IconButton.js +2 -16
  110. package/dist/Input/Input.js +7 -56
  111. package/dist/LineChart/LineChart.d.ts +3 -0
  112. package/dist/LineChart/LineChart.js +491 -0
  113. package/dist/LineChart/LineChart.lib.d.ts +24 -0
  114. package/dist/LineChart/LineChart.lib.js +132 -0
  115. package/dist/LineChart/LineChart.styled.d.ts +57 -0
  116. package/dist/LineChart/LineChart.styled.js +150 -0
  117. package/dist/LineChart/LineChart.types.d.ts +192 -0
  118. package/dist/LineChart/LineChart.types.js +1 -0
  119. package/dist/LineChart/index.d.ts +3 -0
  120. package/dist/LineChart/index.js +2 -0
  121. package/dist/PieChart/PieChart.d.ts +2 -0
  122. package/dist/PieChart/PieChart.js +161 -0
  123. package/dist/PieChart/PieChart.lib.d.ts +5 -0
  124. package/dist/PieChart/PieChart.lib.js +19 -0
  125. package/dist/PieChart/PieChart.styled.d.ts +49 -0
  126. package/dist/PieChart/PieChart.styled.js +161 -0
  127. package/dist/PieChart/PieChart.types.d.ts +99 -0
  128. package/dist/PieChart/PieChart.types.js +1 -0
  129. package/dist/PieChart/index.d.ts +2 -0
  130. package/dist/PieChart/index.js +1 -0
  131. package/dist/Pill/Pill.js +8 -79
  132. package/dist/Popover/Popover.context.d.ts +2 -1
  133. package/dist/Popover/Popover.js +5 -2
  134. package/dist/Popover/Popover.styles.d.ts +1 -6
  135. package/dist/Popover/Popover.styles.js +11 -28
  136. package/dist/Popover/Popover.transitions.d.ts +4 -2
  137. package/dist/Popover/Popover.transitions.js +23 -49
  138. package/dist/Popover/PopoverDropdown.js +6 -8
  139. package/dist/Popover/PopoverTarget.js +6 -3
  140. package/dist/SegmentedControl/SegmentedControl.utils.d.ts +2 -2
  141. package/dist/SegmentedControl/SegmentedControl.utils.js +3 -30
  142. package/dist/SelectBox/SelectBox.js +3 -3
  143. package/dist/SelectBox/select-box.styled-components.d.ts +3 -1
  144. package/dist/SelectBox/select-box.styled-components.js +10 -48
  145. package/dist/SuperDatePicker/SuperDatePicker.d.ts +74 -0
  146. package/dist/SuperDatePicker/SuperDatePicker.js +557 -0
  147. package/dist/SuperDatePicker/index.d.ts +2 -0
  148. package/dist/SuperDatePicker/index.js +2 -0
  149. package/dist/Switch/Switch.d.ts +2 -2
  150. package/dist/Switch/Switch.js +18 -83
  151. package/dist/Table/StateStorage.d.ts +4 -0
  152. package/dist/Table/StateStorage.js +13 -0
  153. package/dist/Table/Table.js +160 -12
  154. package/dist/Table/TableComponents.d.ts +10 -0
  155. package/dist/Table/TableComponents.js +57 -0
  156. package/dist/Table/TableDefaults.d.ts +7 -0
  157. package/dist/Table/TableDefaults.js +7 -0
  158. package/dist/Table/TableProvider.js +263 -71
  159. package/dist/Table/TableRow.js +15 -10
  160. package/dist/Table/types.d.ts +64 -0
  161. package/dist/TagBox/TagBox.js +18 -76
  162. package/dist/TextArea/TextArea.js +4 -23
  163. package/dist/TextInput/TextInput.js +12 -6
  164. package/dist/Utilities/parseTimestamp.js +11 -6
  165. package/dist/core/ArrowButton.d.ts +2 -0
  166. package/dist/core/ArrowButton.js +7 -3
  167. package/dist/core/ClearButton.d.ts +2 -0
  168. package/dist/core/ClearButton.js +7 -3
  169. package/dist/core/controlSizes.d.ts +34 -0
  170. package/dist/core/controlSizes.js +190 -0
  171. package/dist/core/index.d.ts +1 -0
  172. package/dist/core/index.js +1 -0
  173. package/dist/index.d.ts +1 -0
  174. package/dist/index.js +1 -0
  175. package/package.json +5 -1
@@ -1,25 +1,11 @@
1
1
  import styled from "styled-components";
2
2
  import { Button } from "..";
3
+ import { getControlSizeTokens } from "../core";
3
4
  const IconButton = styled(Button) `
4
5
  padding: ${({ size, variant }) => {
5
6
  if (variant === "text")
6
7
  return `0px 0px`;
7
- switch (size) {
8
- case "xxs":
9
- return `0px 4px`;
10
- case "xs":
11
- return `0px 4px`;
12
- case "sm":
13
- return `0px 6px`;
14
- case "md":
15
- return `0px 8px`;
16
- case "lg":
17
- return `0px 10px`;
18
- case "xl":
19
- return `0px 12px`;
20
- default:
21
- return `0px 6px`;
22
- }
8
+ return `0px ${getControlSizeTokens(size).iconButtonPaddingX}px`;
23
9
  }};
24
10
  `;
25
11
  export default IconButton;
@@ -11,6 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import styled from "styled-components";
14
+ import { getControlSizeTokens, } from "../core";
14
15
  import { forwardRef } from "react";
15
16
  const StyledInput = styled.input `
16
17
  font-family: ${({ theme }) => theme.typography.fontFamily};
@@ -20,41 +21,11 @@ const StyledInput = styled.input `
20
21
  box-sizing: border-box;
21
22
 
22
23
  color: ${({ theme }) => theme.palette.text.primary};
23
- font-size: ${({ size }) => size === "xs"
24
- ? "11px"
25
- : size === "sm"
26
- ? "13px"
27
- : size === "md"
28
- ? "15px"
29
- : size === "lg"
30
- ? "17px"
31
- : size === "xl"
32
- ? "19px"
33
- : "13px"};
24
+ font-size: ${({ size }) => `${getControlSizeTokens(size).fontSize}px`};
34
25
 
35
- height: ${({ size }) => size === "xs"
36
- ? "26px"
37
- : size === "sm"
38
- ? "30px"
39
- : size === "md"
40
- ? "36px"
41
- : size === "lg"
42
- ? "42px"
43
- : size === "xl"
44
- ? "50px"
45
- : "30px"};
26
+ height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
46
27
 
47
- min-height: ${({ size }) => size === "xs"
48
- ? "26px"
49
- : size === "sm"
50
- ? "30px"
51
- : size === "md"
52
- ? "36px"
53
- : size === "lg"
54
- ? "42px"
55
- : size === "xl"
56
- ? "50px"
57
- : "30px"};
28
+ min-height: ${({ size }) => `${getControlSizeTokens(size).height}px`};
58
29
 
59
30
  transition: border 0.1s ease-in-out;
60
31
  border-radius: 4px;
@@ -74,17 +45,7 @@ const StyledInput = styled.input `
74
45
  }
75
46
  }};
76
47
 
77
- padding: ${({ size }) => size === "xs"
78
- ? "0px 8px"
79
- : size === "sm"
80
- ? "0px 10px"
81
- : size === "md"
82
- ? "0px 12px"
83
- : size === "lg"
84
- ? "0px 14px"
85
- : size === "xl"
86
- ? "0px 16px"
87
- : "0px 10px"};
48
+ padding: ${({ size }) => `0px ${getControlSizeTokens(size).inputPaddingX}px`};
88
49
 
89
50
  width: ${({ width }) => {
90
51
  if (typeof width === "undefined")
@@ -113,17 +74,7 @@ const StyledInput = styled.input `
113
74
  }};
114
75
 
115
76
  ::placeholder {
116
- font-size: ${({ size }) => size === "xs"
117
- ? "10px"
118
- : size === "sm"
119
- ? "12px"
120
- : size === "md"
121
- ? "14px"
122
- : size === "lg"
123
- ? "16px"
124
- : size === "xl"
125
- ? "18px"
126
- : "12px"};
77
+ font-size: ${({ size }) => `${getControlSizeTokens(size).placeholderFontSize}px`};
127
78
  }
128
79
 
129
80
  &:focus {
@@ -131,7 +82,7 @@ const StyledInput = styled.input `
131
82
  }
132
83
 
133
84
  &[data-button-right="true"] {
134
- padding-right: 36px;
85
+ padding-right: ${({ size }) => `${getControlSizeTokens(size).adornmentWidth}px`};
135
86
  }
136
87
 
137
88
  &[readOnly] {
@@ -0,0 +1,3 @@
1
+ import { LineChartProps } from "./LineChart.types";
2
+ export declare const LineChart: <TData>({ data, series, seriesLabel, width, height, 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, showTooltips, valueFormatter, xValueFormatter, xTickFormatter, yTickFormatter, labelFormatter, tooltipFormatter, onPointClick, className, ...props }: LineChartProps<TData>) => import("react/jsx-runtime").JSX.Element;
3
+ export default LineChart;
@@ -0,0 +1,491 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { scaleLinear, scalePoint, scaleTime } from "d3-scale";
14
+ import { useCallback, useEffect, useId, useMemo, useRef, useState, } from "react";
15
+ import { useTheme } from "styled-components";
16
+ import { buildAreaPath, buildLinePath, clamp, easeOutCubic, formatDefaultValue, getGradientStops, getPointKey, getSeriesKey, getSeriesLabelText, getValueDomain, measureSvgPath, mergeChartMargin, normalizeTickValue, parseLineChartXValue, resolveXAxisType, useThemeColor, useThemeColors, } from "./LineChart.lib";
17
+ import { StyledArea, StyledAxisLine, StyledAxisText, StyledChartFrame, StyledChartScroller, StyledContainer, StyledEmptyState, StyledGridLine, StyledHoverTarget, StyledLegend, StyledLegendItem, StyledLegendLabel, StyledLegendLine, StyledLegendValue, StyledLine, StyledPoint, StyledSvg, StyledTooltip, StyledTooltipHeader, StyledTooltipLabel, StyledTooltipMeta, StyledTooltipSwatch, StyledValueLabel, } from "./LineChart.styled";
18
+ export const LineChart = (_a) => {
19
+ var _b, _c, _d;
20
+ var { data, series, seriesLabel = "Series", width = 720, height = 320, 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, showTooltips = false, valueFormatter, xValueFormatter, xTickFormatter, yTickFormatter, labelFormatter, tooltipFormatter, onPointClick, className } = _a, props = __rest(_a, ["data", "series", "seriesLabel", "width", "height", "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", "showTooltips", "valueFormatter", "xValueFormatter", "xTickFormatter", "yTickFormatter", "labelFormatter", "tooltipFormatter", "onPointClick", "className"]);
21
+ const descriptionId = useId();
22
+ const gradientBaseId = useId();
23
+ const theme = useTheme();
24
+ const containerRef = useRef(null);
25
+ const chartFrameRef = useRef(null);
26
+ const tooltipRef = useRef(null);
27
+ const linePathRefs = useRef({});
28
+ const [activePointKey, setActivePointKey] = useState(null);
29
+ const [activeSeriesKey, setActiveSeriesKey] = useState(null);
30
+ const [activeTooltip, setActiveTooltip] = useState(null);
31
+ const [tooltipSize, setTooltipSize] = useState({ width: 0, height: 0 });
32
+ const [animationProgress, setAnimationProgress] = useState(animateOnRender ? 0 : 1);
33
+ const [lineLengths, setLineLengths] = useState({});
34
+ const themeLineColor = useThemeColor(lineColor);
35
+ const themeColors = useThemeColors(colors);
36
+ const resolvedMargin = mergeChartMargin(margin, showXAxisLabels, showYAxisLabels, showLabels);
37
+ const safeWidth = Math.max(width, 240);
38
+ const safeHeight = Math.max(height, 200);
39
+ const plotWidth = Math.max(safeWidth - resolvedMargin.left - resolvedMargin.right, 1);
40
+ const plotHeight = Math.max(safeHeight - resolvedMargin.top - resolvedMargin.bottom, 1);
41
+ const resolvedGlobalLineWidth = Math.max(lineWidth, 1);
42
+ const resolvedGlobalLineOpacity = clamp(lineOpacity, 0, 1);
43
+ const resolvedGlobalAreaOpacity = clamp(areaOpacity, 0, 1);
44
+ const resolvedGlobalPointRadius = Math.max(pointRadius, 0);
45
+ const resolvedGlobalActivePointRadius = Math.max(activePointRadius, resolvedGlobalPointRadius);
46
+ const resolvedPointOpacity = clamp(pointOpacity, 0, 1);
47
+ const isMultiSeries = ((_b = series === null || series === void 0 ? void 0 : series.length) !== null && _b !== void 0 ? _b : 0) > 0;
48
+ const normalizedInputSeries = useMemo(() => {
49
+ if (series === null || series === void 0 ? void 0 : series.length) {
50
+ return series.map((seriesItem, seriesIndex) => {
51
+ const fallbackLabel = `Series ${seriesIndex + 1}`;
52
+ return {
53
+ key: getSeriesKey(seriesItem, seriesIndex),
54
+ label: seriesItem.label,
55
+ labelText: getSeriesLabelText(seriesItem.label, fallbackLabel),
56
+ sourceSeries: seriesItem,
57
+ color: seriesItem.color,
58
+ colorGradient: seriesItem.colorGradient,
59
+ lineDasharray: seriesItem.lineDasharray,
60
+ lineWidth: seriesItem.lineWidth,
61
+ lineOpacity: seriesItem.lineOpacity,
62
+ showArea: seriesItem.showArea,
63
+ areaColor: seriesItem.areaColor,
64
+ areaOpacity: seriesItem.areaOpacity,
65
+ showPoints: seriesItem.showPoints,
66
+ pointColor: seriesItem.pointColor,
67
+ pointRadius: seriesItem.pointRadius,
68
+ activePointRadius: seriesItem.activePointRadius,
69
+ data: seriesItem.data,
70
+ };
71
+ });
72
+ }
73
+ if (data === null || data === void 0 ? void 0 : data.length) {
74
+ return [
75
+ {
76
+ key: "series-0",
77
+ label: seriesLabel,
78
+ labelText: getSeriesLabelText(seriesLabel, "Series"),
79
+ data,
80
+ },
81
+ ];
82
+ }
83
+ return [];
84
+ }, [data, series, seriesLabel]);
85
+ const parsedSeriesInput = useMemo(() => {
86
+ const seriesEntries = normalizedInputSeries.map((inputSeries, seriesIndex) => {
87
+ const parsedPoints = inputSeries.data
88
+ .map((datum, pointIndex) => {
89
+ const parsedX = parseLineChartXValue(datum.x);
90
+ if (parsedX == null || !Number.isFinite(datum.y))
91
+ return null;
92
+ 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: "" });
93
+ })
94
+ .filter(Boolean);
95
+ return Object.assign(Object.assign({}, inputSeries), { points: parsedPoints });
96
+ });
97
+ const allPoints = seriesEntries.flatMap((entry) => entry.points);
98
+ return {
99
+ resolvedXAxisType: resolveXAxisType(allPoints, xAxisType),
100
+ seriesEntries,
101
+ };
102
+ }, [normalizedInputSeries, xAxisType]);
103
+ const resolvedSeries = useMemo(() => {
104
+ return parsedSeriesInput.seriesEntries
105
+ .map((seriesEntry, seriesIndex) => {
106
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
107
+ const resolvedColor = (_a = seriesEntry.color) !== null && _a !== void 0 ? _a : (normalizedInputSeries.length === 1
108
+ ? themeLineColor
109
+ : themeColors[seriesIndex % themeColors.length]);
110
+ const resolvedGradientStops = getGradientStops((_b = seriesEntry.colorGradient) !== null && _b !== void 0 ? _b : (normalizedInputSeries.length === 1 ? colorGradient : undefined));
111
+ const resolvedPointRadius = Math.max((_c = seriesEntry.pointRadius) !== null && _c !== void 0 ? _c : resolvedGlobalPointRadius, 0);
112
+ const resolvedActivePointRadius = Math.max((_d = seriesEntry.activePointRadius) !== null && _d !== void 0 ? _d : resolvedGlobalActivePointRadius, resolvedPointRadius);
113
+ const points = seriesEntry.points
114
+ .map((point) => (Object.assign(Object.assign({}, point), { xType: parsedSeriesInput.resolvedXAxisType, seriesColor: resolvedColor })))
115
+ .sort((left, right) => {
116
+ if (parsedSeriesInput.resolvedXAxisType === "point") {
117
+ return left.index - right.index;
118
+ }
119
+ const leftValue = left.parsedX instanceof Date
120
+ ? left.parsedX.getTime()
121
+ : Number(left.parsedX);
122
+ const rightValue = right.parsedX instanceof Date
123
+ ? right.parsedX.getTime()
124
+ : Number(right.parsedX);
125
+ return leftValue - rightValue;
126
+ });
127
+ return {
128
+ key: seriesEntry.key,
129
+ label: seriesEntry.label,
130
+ labelText: seriesEntry.labelText,
131
+ color: resolvedColor,
132
+ gradientStops: resolvedGradientStops,
133
+ lineDasharray: (_e = seriesEntry.lineDasharray) !== null && _e !== void 0 ? _e : lineDasharray,
134
+ lineWidth: Math.max((_f = seriesEntry.lineWidth) !== null && _f !== void 0 ? _f : resolvedGlobalLineWidth, 1),
135
+ lineOpacity: clamp((_g = seriesEntry.lineOpacity) !== null && _g !== void 0 ? _g : resolvedGlobalLineOpacity, 0, 1),
136
+ showArea: (_h = seriesEntry.showArea) !== null && _h !== void 0 ? _h : showArea,
137
+ areaColor: (_k = (_j = seriesEntry.areaColor) !== null && _j !== void 0 ? _j : areaColor) !== null && _k !== void 0 ? _k : resolvedColor,
138
+ areaOpacity: clamp((_l = seriesEntry.areaOpacity) !== null && _l !== void 0 ? _l : resolvedGlobalAreaOpacity, 0, 1),
139
+ showPoints: (_m = seriesEntry.showPoints) !== null && _m !== void 0 ? _m : showPoints,
140
+ pointColor: (_p = (_o = seriesEntry.pointColor) !== null && _o !== void 0 ? _o : pointColor) !== null && _p !== void 0 ? _p : resolvedColor,
141
+ pointRadius: resolvedPointRadius,
142
+ activePointRadius: resolvedActivePointRadius,
143
+ sourceSeries: seriesEntry.sourceSeries,
144
+ points,
145
+ };
146
+ })
147
+ .filter((seriesEntry) => seriesEntry.points.length > 0);
148
+ }, [
149
+ areaColor,
150
+ colorGradient,
151
+ lineDasharray,
152
+ normalizedInputSeries.length,
153
+ parsedSeriesInput.resolvedXAxisType,
154
+ parsedSeriesInput.seriesEntries,
155
+ pointColor,
156
+ resolvedGlobalActivePointRadius,
157
+ resolvedGlobalAreaOpacity,
158
+ resolvedGlobalLineOpacity,
159
+ resolvedGlobalLineWidth,
160
+ resolvedGlobalPointRadius,
161
+ showArea,
162
+ showPoints,
163
+ themeColors,
164
+ themeLineColor,
165
+ ]);
166
+ const allPoints = useMemo(() => resolvedSeries.flatMap((seriesEntry) => seriesEntry.points), [resolvedSeries]);
167
+ const resolvedXAxisType = parsedSeriesInput.resolvedXAxisType;
168
+ const resolvedPointBorderColor = pointBorderColor !== null && pointBorderColor !== void 0 ? pointBorderColor : theme.palette.background.paper;
169
+ const timeScale = useMemo(() => {
170
+ if (resolvedXAxisType !== "time")
171
+ return null;
172
+ const timeValues = allPoints
173
+ .map((point) => (point.parsedX instanceof Date ? point.parsedX.getTime() : null))
174
+ .filter((value) => value != null);
175
+ const min = Math.min(...timeValues);
176
+ const max = Math.max(...timeValues);
177
+ const scale = scaleTime()
178
+ .domain([new Date(min), new Date(max === min ? min + 1 : max)])
179
+ .range([0, plotWidth]);
180
+ scale.nice(Math.max(xTickCount, 2));
181
+ return scale;
182
+ }, [allPoints, plotWidth, resolvedXAxisType, xTickCount]);
183
+ const linearScale = useMemo(() => {
184
+ if (resolvedXAxisType !== "linear")
185
+ return null;
186
+ const numericValues = allPoints.map((point) => Number(point.parsedX));
187
+ const min = Math.min(...numericValues);
188
+ const max = Math.max(...numericValues);
189
+ const scale = scaleLinear()
190
+ .domain([min, max === min ? min + 1 : max])
191
+ .range([0, plotWidth]);
192
+ scale.nice(Math.max(xTickCount, 2));
193
+ return scale;
194
+ }, [allPoints, plotWidth, resolvedXAxisType, xTickCount]);
195
+ const pointScale = useMemo(() => {
196
+ if (resolvedXAxisType !== "point")
197
+ return null;
198
+ const domain = Array.from(new Set(allPoints.map((point) => String(point.parsedX))));
199
+ return scalePoint()
200
+ .domain(domain)
201
+ .range([0, plotWidth])
202
+ .padding(0.4);
203
+ }, [allPoints, plotWidth, resolvedXAxisType]);
204
+ const yScale = useMemo(() => {
205
+ const scale = scaleLinear()
206
+ .domain(getValueDomain(allPoints.map((point) => point.y), yMin, yMax))
207
+ .range([plotHeight, 0]);
208
+ if (yMin == null || yMax == null) {
209
+ scale.nice(Math.max(yTickCount, 2));
210
+ }
211
+ return scale;
212
+ }, [allPoints, plotHeight, yMax, yMin, yTickCount]);
213
+ const getPointX = useCallback((point) => {
214
+ var _a, _b, _c;
215
+ if (resolvedXAxisType === "time") {
216
+ return (_a = timeScale === null || timeScale === void 0 ? void 0 : timeScale(point.parsedX)) !== null && _a !== void 0 ? _a : 0;
217
+ }
218
+ if (resolvedXAxisType === "linear") {
219
+ return (_b = linearScale === null || linearScale === void 0 ? void 0 : linearScale(Number(point.parsedX))) !== null && _b !== void 0 ? _b : 0;
220
+ }
221
+ return (_c = pointScale === null || pointScale === void 0 ? void 0 : pointScale(String(point.parsedX))) !== null && _c !== void 0 ? _c : 0;
222
+ }, [linearScale, pointScale, resolvedXAxisType, timeScale]);
223
+ const getPointY = useCallback((point) => yScale(point.y), [yScale]);
224
+ 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
225
+ ? buildAreaPath(seriesEntry.points, getPointX, getPointY, plotHeight, curve)
226
+ : null }))), [curve, getPointX, gradientBaseId, plotHeight, resolvedSeries]);
227
+ const renderedSeriesKey = useMemo(() => renderedSeries
228
+ .map((seriesEntry) => {
229
+ var _a, _b;
230
+ return `${String(seriesEntry.key)}:${(_a = seriesEntry.linePath) !== null && _a !== void 0 ? _a : ""}:${(_b = seriesEntry.areaPath) !== null && _b !== void 0 ? _b : ""}`;
231
+ })
232
+ .join("|"), [renderedSeries]);
233
+ useEffect(() => {
234
+ const nextLineLengths = {};
235
+ renderedSeries.forEach((seriesEntry) => {
236
+ var _a;
237
+ nextLineLengths[String(seriesEntry.key)] = measureSvgPath((_a = linePathRefs.current[String(seriesEntry.key)]) !== null && _a !== void 0 ? _a : null);
238
+ });
239
+ setLineLengths((currentLineLengths) => {
240
+ const currentKeys = Object.keys(currentLineLengths);
241
+ const nextKeys = Object.keys(nextLineLengths);
242
+ if (currentKeys.length !== nextKeys.length) {
243
+ return nextLineLengths;
244
+ }
245
+ for (const key of nextKeys) {
246
+ if (currentLineLengths[key] !== nextLineLengths[key]) {
247
+ return nextLineLengths;
248
+ }
249
+ }
250
+ return currentLineLengths;
251
+ });
252
+ }, [renderedSeries, renderedSeriesKey]);
253
+ useEffect(() => {
254
+ var _a;
255
+ if (!animateOnRender || renderedSeries.every((seriesEntry) => !seriesEntry.linePath)) {
256
+ setAnimationProgress(1);
257
+ return;
258
+ }
259
+ const prefersReducedMotion = typeof window !== "undefined" &&
260
+ ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, "(prefers-reduced-motion: reduce)").matches);
261
+ if (prefersReducedMotion) {
262
+ setAnimationProgress(1);
263
+ return;
264
+ }
265
+ let animationFrame = 0;
266
+ let startTime = null;
267
+ const safeDuration = Math.max(animationDuration, 0);
268
+ setAnimationProgress(0);
269
+ const runAnimation = (timestamp) => {
270
+ if (startTime == null)
271
+ startTime = timestamp;
272
+ const elapsed = timestamp - startTime;
273
+ const progress = safeDuration === 0 ? 1 : easeOutCubic(clamp(elapsed / safeDuration, 0, 1));
274
+ setAnimationProgress(progress);
275
+ if (progress < 1) {
276
+ animationFrame = window.requestAnimationFrame(runAnimation);
277
+ }
278
+ };
279
+ animationFrame = window.requestAnimationFrame(runAnimation);
280
+ return () => {
281
+ window.cancelAnimationFrame(animationFrame);
282
+ };
283
+ }, [animateOnRender, animationDuration, renderedSeriesKey]);
284
+ const xTicks = useMemo(() => {
285
+ var _a;
286
+ if (resolvedXAxisType === "time" && timeScale) {
287
+ return timeScale.ticks(Math.max(xTickCount, 2));
288
+ }
289
+ if (resolvedXAxisType === "linear" && linearScale) {
290
+ return linearScale
291
+ .ticks(Math.max(xTickCount, 2))
292
+ .map((tick) => normalizeTickValue(tick));
293
+ }
294
+ const domain = (_a = pointScale === null || pointScale === void 0 ? void 0 : pointScale.domain()) !== null && _a !== void 0 ? _a : [];
295
+ if (domain.length <= Math.max(xTickCount, 2))
296
+ return domain;
297
+ const step = Math.ceil(domain.length / Math.max(xTickCount, 2));
298
+ return domain.filter((_, index) => index % step === 0);
299
+ }, [linearScale, pointScale, resolvedXAxisType, timeScale, xTickCount]);
300
+ const yTicks = useMemo(() => Array.from(new Set(yScale
301
+ .ticks(Math.max(yTickCount, 2))
302
+ .map((tick) => normalizeTickValue(tick)))), [yScale, yTickCount]);
303
+ const formatValue = (datum, sourceSeries) => { var _a; return (_a = valueFormatter === null || valueFormatter === void 0 ? void 0 : valueFormatter(datum.y, datum, sourceSeries)) !== null && _a !== void 0 ? _a : formatDefaultValue(datum.y); };
304
+ const formatXValue = (datum, sourceSeries) => {
305
+ var _a;
306
+ 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));
307
+ };
308
+ const formatXTick = (value) => {
309
+ var _a;
310
+ return (_a = xTickFormatter === null || xTickFormatter === void 0 ? void 0 : xTickFormatter(value)) !== null && _a !== void 0 ? _a : (value instanceof Date
311
+ ? new Intl.DateTimeFormat(undefined, {
312
+ month: "short",
313
+ day: "numeric",
314
+ }).format(value)
315
+ : String(value));
316
+ };
317
+ const formatYTick = (value) => { var _a; return (_a = yTickFormatter === null || yTickFormatter === void 0 ? void 0 : yTickFormatter(value)) !== null && _a !== void 0 ? _a : formatDefaultValue(value); };
318
+ const findNearestPoint = (clientX, clientY) => {
319
+ if (!chartFrameRef.current)
320
+ return null;
321
+ const chartRect = chartFrameRef.current.getBoundingClientRect();
322
+ const localX = clamp(clientX - chartRect.left - resolvedMargin.left, 0, plotWidth);
323
+ const localY = clamp(clientY - chartRect.top - resolvedMargin.top, 0, plotHeight);
324
+ let nearestPoint = null;
325
+ let nearestDistance = Number.POSITIVE_INFINITY;
326
+ for (const point of allPoints) {
327
+ const pointX = getPointX(point);
328
+ const pointY = getPointY(point);
329
+ const dx = pointX - localX;
330
+ const dy = pointY - localY;
331
+ const distance = dx * dx + dy * dy * 0.18;
332
+ if (distance < nearestDistance) {
333
+ nearestDistance = distance;
334
+ nearestPoint = point;
335
+ }
336
+ }
337
+ return nearestPoint;
338
+ };
339
+ const updateActivePointFromEvent = (event, triggerTooltip) => {
340
+ const nearestPoint = findNearestPoint(event.clientX, event.clientY);
341
+ if (!nearestPoint)
342
+ return;
343
+ setActivePointKey(nearestPoint.key);
344
+ if (!triggerTooltip)
345
+ return;
346
+ setActiveTooltip({
347
+ pointKey: nearestPoint.key,
348
+ x: resolvedMargin.left + getPointX(nearestPoint),
349
+ y: resolvedMargin.top + getPointY(nearestPoint),
350
+ });
351
+ };
352
+ const activePoint = (showTooltips || showPoints || onPointClick) && activePointKey != null
353
+ ? allPoints.find((point) => point.key === activePointKey)
354
+ : null;
355
+ const highlightedSeriesKey = (_c = activeSeriesKey !== null && activeSeriesKey !== void 0 ? activeSeriesKey : activePoint === null || activePoint === void 0 ? void 0 : activePoint.seriesKey) !== null && _c !== void 0 ? _c : null;
356
+ const activeSeries = activePoint
357
+ ? renderedSeries.find((seriesEntry) => seriesEntry.key === activePoint.seriesKey)
358
+ : null;
359
+ const tooltipStyle = useMemo(() => {
360
+ if (!activeTooltip ||
361
+ !containerRef.current ||
362
+ !chartFrameRef.current ||
363
+ !activePoint) {
364
+ return null;
365
+ }
366
+ const containerRect = containerRef.current.getBoundingClientRect();
367
+ const chartRect = chartFrameRef.current.getBoundingClientRect();
368
+ const chartLeft = chartRect.left - containerRect.left;
369
+ const chartTop = chartRect.top - containerRect.top;
370
+ const minLeft = chartLeft + 8;
371
+ const maxLeft = chartLeft + chartRect.width - tooltipSize.width - 8;
372
+ const minTop = chartTop + 8;
373
+ const maxTop = chartTop + chartRect.height - tooltipSize.height - 8;
374
+ return {
375
+ left: clamp(activeTooltip.x + 14, minLeft, Math.max(minLeft, maxLeft)),
376
+ top: clamp(activeTooltip.y - tooltipSize.height / 2, minTop, Math.max(minTop, maxTop)),
377
+ };
378
+ }, [activePoint, activeTooltip, tooltipSize.height, tooltipSize.width]);
379
+ useEffect(() => {
380
+ if (!activePoint || !tooltipRef.current) {
381
+ setTooltipSize({ width: 0, height: 0 });
382
+ return;
383
+ }
384
+ setTooltipSize({
385
+ width: tooltipRef.current.offsetWidth,
386
+ height: tooltipRef.current.offsetHeight,
387
+ });
388
+ }, [activePoint]);
389
+ const description = allPoints
390
+ .map((point) => `${point.seriesLabelText}, ${formatXValue(point, activeSeries === null || activeSeries === void 0 ? void 0 : activeSeries.sourceSeries)}: ${formatDefaultValue(point.y)}`)
391
+ .join(", ");
392
+ const shouldAnimateStroke = animateOnRender && animationProgress < 1;
393
+ const shouldShowDataLabels = showLabels && allPoints.length <= 24;
394
+ return (_jsxs(StyledContainer, Object.assign({ ref: containerRef, className: className }, props, { children: [allPoints.length === 0 ? (_jsx(StyledEmptyState, { "$width": safeWidth, "$height": safeHeight, children: emptyLabel })) : (_jsx(StyledChartScroller, { children: _jsx(StyledChartFrame, { ref: chartFrameRef, children: _jsxs(StyledSvg, { 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
395
+ .filter((seriesEntry) => { var _a; return (_a = seriesEntry.gradientStops) === null || _a === void 0 ? void 0 : _a.length; })
396
+ .map((seriesEntry) => {
397
+ var _a;
398
+ 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) => {
399
+ var _a, _b;
400
+ return (_jsx("stop", { offset: `${((_a = seriesEntry.gradientStops) !== null && _a !== void 0 ? _a : []).length === 1
401
+ ? 100
402
+ : (index /
403
+ (((_b = seriesEntry.gradientStops) !== null && _b !== void 0 ? _b : []).length - 1)) *
404
+ 100}%`, stopColor: stop }, `${stop}-${index}`));
405
+ }) }, seriesEntry.gradientId));
406
+ }) }), showGridLines &&
407
+ 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 &&
408
+ 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 &&
409
+ xTicks.map((tick, index) => {
410
+ var _a, _b, _c;
411
+ const x = resolvedXAxisType === "time"
412
+ ? (_a = timeScale === null || timeScale === void 0 ? void 0 : timeScale(tick)) !== null && _a !== void 0 ? _a : 0
413
+ : resolvedXAxisType === "linear"
414
+ ? (_b = linearScale === null || linearScale === void 0 ? void 0 : linearScale(tick)) !== null && _b !== void 0 ? _b : 0
415
+ : (_c = pointScale === null || pointScale === void 0 ? void 0 : pointScale(String(tick))) !== null && _c !== void 0 ? _c : 0;
416
+ return (_jsx(StyledAxisText, { x: resolvedMargin.left + x, y: resolvedMargin.top + plotHeight + 20, textAnchor: "middle", children: formatXTick(tick) }, `tick-x-${index}`));
417
+ }), _jsxs("g", { transform: `translate(${resolvedMargin.left}, ${resolvedMargin.top})`, children: [_jsx(StyledHoverTarget, { x: 0, y: 0, width: plotWidth, height: plotHeight, onMouseEnter: (event) => {
418
+ if (!showTooltips && !showPoints && !onPointClick)
419
+ return;
420
+ updateActivePointFromEvent(event, showTooltips);
421
+ }, onMouseMove: (event) => {
422
+ if (!showTooltips && !showPoints && !onPointClick)
423
+ return;
424
+ updateActivePointFromEvent(event, showTooltips);
425
+ }, onMouseLeave: () => {
426
+ setActivePointKey(null);
427
+ setActiveTooltip(null);
428
+ }, onClick: (event) => {
429
+ if (!onPointClick)
430
+ return;
431
+ const nearestPoint = findNearestPoint(event.clientX, event.clientY);
432
+ const nearestSeries = nearestPoint
433
+ ? renderedSeries.find((seriesEntry) => seriesEntry.key === nearestPoint.seriesKey)
434
+ : null;
435
+ if (nearestPoint) {
436
+ onPointClick(event, nearestPoint, nearestSeries === null || nearestSeries === void 0 ? void 0 : nearestSeries.sourceSeries);
437
+ }
438
+ } }), renderedSeries.map((seriesEntry) => {
439
+ var _a, _b;
440
+ const gradientReference = ((_a = seriesEntry.gradientStops) === null || _a === void 0 ? void 0 : _a.length)
441
+ ? `url(#${seriesEntry.gradientId})`
442
+ : seriesEntry.color;
443
+ const lineLength = (_b = lineLengths[String(seriesEntry.key)]) !== null && _b !== void 0 ? _b : 0;
444
+ const isSeriesActive = highlightedSeriesKey === seriesEntry.key;
445
+ const isSeriesDimmed = highlightedSeriesKey != null && !isSeriesActive;
446
+ 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 *
447
+ animationProgress *
448
+ (isSeriesDimmed ? 0.28 : isSeriesActive ? 1.08 : 1), style: {
449
+ filter: isSeriesActive
450
+ ? "brightness(1.08) saturate(1.06)"
451
+ : undefined,
452
+ opacity: isSeriesDimmed ? 0.7 : 1,
453
+ } })), seriesEntry.linePath && (_jsx(StyledLine, { "$active": isSeriesActive, "$dimmed": isSeriesDimmed, ref: (node) => {
454
+ linePathRefs.current[String(seriesEntry.key)] = node;
455
+ }, d: seriesEntry.linePath, stroke: gradientReference, strokeWidth: isSeriesActive
456
+ ? seriesEntry.lineWidth + 0.8
457
+ : seriesEntry.lineWidth, strokeOpacity: seriesEntry.lineOpacity, strokeDasharray: shouldAnimateStroke && lineLength > 0
458
+ ? `${lineLength} ${lineLength}`
459
+ : seriesEntry.lineDasharray, strokeDashoffset: shouldAnimateStroke && lineLength > 0
460
+ ? lineLength * (1 - animationProgress)
461
+ : 0 }))] }, seriesEntry.key));
462
+ }), (showPoints || activePoint != null) &&
463
+ renderedSeries.map((seriesEntry) => seriesEntry.points.map((point) => {
464
+ var _a;
465
+ const isActive = activePointKey === point.key;
466
+ const shouldRender = seriesEntry.showPoints || isActive;
467
+ if (!shouldRender)
468
+ return null;
469
+ return (_jsx(StyledPoint, { "$active": isActive, cx: getPointX(point), cy: getPointY(point), r: isActive
470
+ ? seriesEntry.activePointRadius
471
+ : 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: () => {
472
+ if (!showTooltips)
473
+ setActivePointKey(null);
474
+ }, onClick: (event) => onPointClick === null || onPointClick === void 0 ? void 0 : onPointClick(event, point, seriesEntry.sourceSeries), onKeyDown: (event) => {
475
+ if (event.key !== "Enter" && event.key !== " ")
476
+ return;
477
+ event.preventDefault();
478
+ onPointClick === null || onPointClick === void 0 ? void 0 : onPointClick(event, point, seriesEntry.sourceSeries);
479
+ } }, point.key));
480
+ })), shouldShowDataLabels &&
481
+ renderedSeries.map((seriesEntry) => seriesEntry.points.map((point) => {
482
+ var _a;
483
+ 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}`));
484
+ }))] })] }) }) })), 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) => {
485
+ const latestPoint = seriesEntry.points[seriesEntry.points.length - 1];
486
+ if (!latestPoint)
487
+ return null;
488
+ 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}`));
489
+ }) }))] })));
490
+ };
491
+ export default LineChart;
@@ -0,0 +1,24 @@
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;