@cloudtower/eagle 4100.0.18 → 4100.0.19

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 (266) hide show
  1. package/dist/cjs/core/AccordionCard/index.js +1 -1
  2. package/dist/cjs/core/Alert/alert.style.js +2 -2
  3. package/dist/cjs/core/Antd5Tree/Antd5Tree.style.js +1 -1
  4. package/dist/cjs/core/Avatar/index.js +1 -1
  5. package/dist/cjs/core/Banner/banner.style.js +4 -4
  6. package/dist/cjs/core/BasicCTError/BasicCTError.style.js +1 -1
  7. package/dist/cjs/core/BlankState/style.js +1 -1
  8. package/dist/cjs/core/Breadcrumb/index.js +1 -1
  9. package/dist/cjs/core/Button/index.js +1 -1
  10. package/dist/cjs/core/ButtonGroup/index.js +2 -2
  11. package/dist/cjs/core/Card/CardBody.js +1 -1
  12. package/dist/cjs/core/Card/CardTitle.js +1 -1
  13. package/dist/cjs/core/Card/CardWrapper.js +2 -2
  14. package/dist/cjs/core/Cascader/cascader.style.js +11 -11
  15. package/dist/cjs/core/Checkbox/checkbox.style.js +1 -1
  16. package/dist/cjs/core/DetailCard/index.js +1 -1
  17. package/dist/cjs/core/DonutChart/index.js +2 -2
  18. package/dist/cjs/core/DropdownMenu/index.js +1 -1
  19. package/dist/cjs/core/ExpandableList/ExpandIcon.js +1 -1
  20. package/dist/cjs/core/ExpandableList/ExpandableContainer.js +1 -1
  21. package/dist/cjs/core/ExpandableList/ExpandableItem.js +2 -2
  22. package/dist/cjs/core/ExpandableList/RoundOrder.js +1 -1
  23. package/dist/cjs/core/FailedLoad/index.js +1 -1
  24. package/dist/cjs/core/FormItem/index.js +1 -1
  25. package/dist/cjs/core/Icon/index.js +1 -1
  26. package/dist/cjs/core/ImmersiveDialog/styles.js +14 -14
  27. package/dist/cjs/core/Input/index.js +1 -1
  28. package/dist/cjs/core/InputGroup/index.js +1 -1
  29. package/dist/cjs/core/InputInteger/index.js +1 -1
  30. package/dist/cjs/core/InputNumber/index.js +1 -1
  31. package/dist/cjs/core/InputPassword/index.js +1 -1
  32. package/dist/cjs/core/InputTagItem/index.js +1 -1
  33. package/dist/cjs/core/LegacySelect/select.style.js +1 -1
  34. package/dist/cjs/core/Legend/index.js +5 -5
  35. package/dist/cjs/core/LineChart/AreaHighlightLayer.js +122 -0
  36. package/dist/cjs/core/LineChart/ForecastLineLayer.js +134 -0
  37. package/dist/cjs/core/LineChart/LineChartActions.js +2 -2
  38. package/dist/cjs/core/LineChart/RenderChart.js +274 -20
  39. package/dist/cjs/core/LineChart/ThresholdIntersectionLayer.js +144 -0
  40. package/dist/cjs/core/LineChart/TooltipFormatter.js +44 -39
  41. package/dist/cjs/core/LineChart/areaHighlightUtils.js +89 -0
  42. package/dist/cjs/core/LineChart/index.js +20 -2
  43. package/dist/cjs/core/LineChart/lineChartDisplayUtils.js +32 -0
  44. package/dist/cjs/core/LineChart/lineSegments.js +90 -0
  45. package/dist/cjs/core/LineChart/styled.js +21 -9
  46. package/dist/cjs/core/LineChart/utils.js +93 -4
  47. package/dist/cjs/core/Link/index.js +1 -1
  48. package/dist/cjs/core/Loading/style.js +4 -4
  49. package/dist/cjs/core/LocalUpload/LocalUpload.style.js +2 -2
  50. package/dist/cjs/core/LogView/LogView.style.js +5 -5
  51. package/dist/cjs/core/MediumDialog/MediumDialog.js +1 -1
  52. package/dist/cjs/core/Metric/styled.js +8 -8
  53. package/dist/cjs/core/Nav/index.js +1 -1
  54. package/dist/cjs/core/Nav/style.js +2 -2
  55. package/dist/cjs/core/Overflow/index.js +2 -2
  56. package/dist/cjs/core/Pagination/index.js +2 -2
  57. package/dist/cjs/core/Progress/components.js +2 -2
  58. package/dist/cjs/core/Progress/index.js +2 -2
  59. package/dist/cjs/core/Progress/progress.style.js +4 -4
  60. package/dist/cjs/core/Progress/progress.widgets.js +2 -2
  61. package/dist/cjs/core/Radio/index.js +3 -3
  62. package/dist/cjs/core/SearchInput/SearchInput.style.js +5 -5
  63. package/dist/cjs/core/SegmentControl/index.js +4 -4
  64. package/dist/cjs/core/Select/select.style.js +4 -4
  65. package/dist/cjs/core/Select/select.widgets.js +3 -3
  66. package/dist/cjs/core/SimplePagination/index.js +2 -2
  67. package/dist/cjs/core/Skeleton/Content.js +1 -1
  68. package/dist/cjs/core/SmallDialog/SmallDialog.style.js +7 -7
  69. package/dist/cjs/core/StatusCapsule/index.js +2 -2
  70. package/dist/cjs/core/StepProgress/index.js +1 -1
  71. package/dist/cjs/core/Steps/style.js +5 -5
  72. package/dist/cjs/core/Styled/index.js +40 -40
  73. package/dist/cjs/core/Switch/index.js +2 -2
  74. package/dist/cjs/core/Tab/Tab.js +1 -1
  75. package/dist/cjs/core/Tab/Tab.style.js +4 -4
  76. package/dist/cjs/core/Table/TableSkeleton.js +1 -1
  77. package/dist/cjs/core/Table/TableWidget.js +1 -1
  78. package/dist/cjs/core/Table/index.js +3 -3
  79. package/dist/cjs/core/TableForm/Columns/FormItem.js +1 -1
  80. package/dist/cjs/core/TableForm/style.js +7 -7
  81. package/dist/cjs/core/Tag/SplitTag.js +1 -1
  82. package/dist/cjs/core/Tag/style.js +5 -5
  83. package/dist/cjs/core/Time/index.js +1 -1
  84. package/dist/cjs/core/TimeZoneSelect/index.js +7 -7
  85. package/dist/cjs/core/Timeline/Timeline.style.js +5 -5
  86. package/dist/cjs/core/Token/index.js +4 -4
  87. package/dist/cjs/core/Token/style.js +1 -1
  88. package/dist/cjs/core/Tooltip/EllipsisTooltipContent.js +1 -1
  89. package/dist/cjs/core/Tooltip/index.js +1 -1
  90. package/dist/cjs/core/Truncate/index.js +1 -1
  91. package/dist/cjs/core/Typo/index.js +58 -58
  92. package/dist/cjs/core/WizardDialog/styles.js +4 -4
  93. package/dist/cjs/coreX/BarChart/index.js +1 -1
  94. package/dist/cjs/coreX/BatchOperation/index.js +2 -2
  95. package/dist/cjs/coreX/ChartWithTooltip/index.js +6 -6
  96. package/dist/cjs/coreX/CheckPointList/checkpointlist.style.js +3 -3
  97. package/dist/cjs/coreX/CircleLoading/index.js +1 -1
  98. package/dist/cjs/coreX/CronCalendar/index.js +4 -4
  99. package/dist/cjs/coreX/CronPlan/index.js +4 -4
  100. package/dist/cjs/coreX/DateRangePicker/DateRangePicker.style.js +12 -12
  101. package/dist/cjs/coreX/DateRangePicker/RelativeTime.js +9 -6
  102. package/dist/cjs/coreX/DateRangePicker/common.js +104 -5
  103. package/dist/cjs/coreX/DateRangePicker/index.js +107 -47
  104. package/dist/cjs/coreX/Dialogs/DeleteDialog/DeleteDialog.js +2 -2
  105. package/dist/cjs/coreX/Dialogs/RejectDialog/RejectDialog.js +6 -6
  106. package/dist/cjs/coreX/GoBackButton/index.js +1 -1
  107. package/dist/cjs/coreX/I18nNameTag/index.js +1 -1
  108. package/dist/cjs/coreX/InfoRowList/InfoRow.js +1 -1
  109. package/dist/cjs/coreX/InfoRowList/InfoRowList.js +4 -4
  110. package/dist/cjs/coreX/KubeConfigModal/KubeConfigModal.style.js +8 -8
  111. package/dist/cjs/coreX/NamesTooltip/index.js +3 -3
  112. package/dist/cjs/coreX/OverflowTooltip/index.js +4 -4
  113. package/dist/cjs/coreX/Sider/index.js +3 -3
  114. package/dist/cjs/coreX/SummaryTable/index.js +5 -5
  115. package/dist/cjs/coreX/SwitchWithText/index.js +1 -1
  116. package/dist/cjs/coreX/TabMenu/index.js +2 -2
  117. package/dist/cjs/coreX/UnderlineTootip/index.js +1 -1
  118. package/dist/cjs/coreX/UnitWithChart/index.js +3 -3
  119. package/dist/cjs/index.js +13 -0
  120. package/dist/cjs/stats1.html +1 -1
  121. package/dist/components.css +4504 -4480
  122. package/dist/esm/core/AccordionCard/index.js +1 -1
  123. package/dist/esm/core/Alert/alert.style.js +2 -2
  124. package/dist/esm/core/Antd5Tree/Antd5Tree.style.js +1 -1
  125. package/dist/esm/core/Avatar/index.js +1 -1
  126. package/dist/esm/core/Banner/banner.style.js +4 -4
  127. package/dist/esm/core/BasicCTError/BasicCTError.style.js +1 -1
  128. package/dist/esm/core/BlankState/style.js +1 -1
  129. package/dist/esm/core/Breadcrumb/index.js +1 -1
  130. package/dist/esm/core/Button/index.js +1 -1
  131. package/dist/esm/core/ButtonGroup/index.js +2 -2
  132. package/dist/esm/core/Card/CardBody.js +1 -1
  133. package/dist/esm/core/Card/CardTitle.js +1 -1
  134. package/dist/esm/core/Card/CardWrapper.js +2 -2
  135. package/dist/esm/core/Cascader/cascader.style.js +11 -11
  136. package/dist/esm/core/Checkbox/checkbox.style.js +1 -1
  137. package/dist/esm/core/DetailCard/index.js +1 -1
  138. package/dist/esm/core/DonutChart/index.js +2 -2
  139. package/dist/esm/core/DropdownMenu/index.js +1 -1
  140. package/dist/esm/core/ExpandableList/ExpandIcon.js +1 -1
  141. package/dist/esm/core/ExpandableList/ExpandableContainer.js +1 -1
  142. package/dist/esm/core/ExpandableList/ExpandableItem.js +2 -2
  143. package/dist/esm/core/ExpandableList/RoundOrder.js +1 -1
  144. package/dist/esm/core/FailedLoad/index.js +1 -1
  145. package/dist/esm/core/FormItem/index.js +1 -1
  146. package/dist/esm/core/Icon/index.js +1 -1
  147. package/dist/esm/core/ImmersiveDialog/styles.js +14 -14
  148. package/dist/esm/core/Input/index.js +1 -1
  149. package/dist/esm/core/InputGroup/index.js +1 -1
  150. package/dist/esm/core/InputInteger/index.js +1 -1
  151. package/dist/esm/core/InputNumber/index.js +1 -1
  152. package/dist/esm/core/InputPassword/index.js +1 -1
  153. package/dist/esm/core/InputTagItem/index.js +1 -1
  154. package/dist/esm/core/LegacySelect/select.style.js +1 -1
  155. package/dist/esm/core/Legend/index.js +5 -5
  156. package/dist/esm/core/LineChart/AreaHighlightLayer.js +115 -0
  157. package/dist/esm/core/LineChart/ForecastLineLayer.js +124 -0
  158. package/dist/esm/core/LineChart/LineChartActions.js +2 -2
  159. package/dist/esm/core/LineChart/RenderChart.js +276 -23
  160. package/dist/esm/core/LineChart/ThresholdIntersectionLayer.js +134 -0
  161. package/dist/esm/core/LineChart/TooltipFormatter.js +41 -39
  162. package/dist/esm/core/LineChart/areaHighlightUtils.js +87 -0
  163. package/dist/esm/core/LineChart/index.js +21 -3
  164. package/dist/esm/core/LineChart/lineChartDisplayUtils.js +26 -0
  165. package/dist/esm/core/LineChart/lineSegments.js +87 -0
  166. package/dist/esm/core/LineChart/styled.js +20 -10
  167. package/dist/esm/core/LineChart/utils.js +91 -5
  168. package/dist/esm/core/Link/index.js +1 -1
  169. package/dist/esm/core/Loading/style.js +4 -4
  170. package/dist/esm/core/LocalUpload/LocalUpload.style.js +2 -2
  171. package/dist/esm/core/LogView/LogView.style.js +5 -5
  172. package/dist/esm/core/MediumDialog/MediumDialog.js +1 -1
  173. package/dist/esm/core/Metric/styled.js +8 -8
  174. package/dist/esm/core/Nav/index.js +1 -1
  175. package/dist/esm/core/Nav/style.js +2 -2
  176. package/dist/esm/core/Overflow/index.js +2 -2
  177. package/dist/esm/core/Pagination/index.js +2 -2
  178. package/dist/esm/core/Progress/components.js +2 -2
  179. package/dist/esm/core/Progress/index.js +2 -2
  180. package/dist/esm/core/Progress/progress.style.js +4 -4
  181. package/dist/esm/core/Progress/progress.widgets.js +2 -2
  182. package/dist/esm/core/Radio/index.js +3 -3
  183. package/dist/esm/core/SearchInput/SearchInput.style.js +5 -5
  184. package/dist/esm/core/SegmentControl/index.js +4 -4
  185. package/dist/esm/core/Select/select.style.js +4 -4
  186. package/dist/esm/core/Select/select.widgets.js +3 -3
  187. package/dist/esm/core/SimplePagination/index.js +2 -2
  188. package/dist/esm/core/Skeleton/Content.js +1 -1
  189. package/dist/esm/core/SmallDialog/SmallDialog.style.js +7 -7
  190. package/dist/esm/core/StatusCapsule/index.js +2 -2
  191. package/dist/esm/core/StepProgress/index.js +1 -1
  192. package/dist/esm/core/Steps/style.js +5 -5
  193. package/dist/esm/core/Styled/index.js +40 -40
  194. package/dist/esm/core/Switch/index.js +2 -2
  195. package/dist/esm/core/Tab/Tab.js +1 -1
  196. package/dist/esm/core/Tab/Tab.style.js +4 -4
  197. package/dist/esm/core/Table/TableSkeleton.js +1 -1
  198. package/dist/esm/core/Table/TableWidget.js +1 -1
  199. package/dist/esm/core/Table/index.js +3 -3
  200. package/dist/esm/core/TableForm/Columns/FormItem.js +1 -1
  201. package/dist/esm/core/TableForm/style.js +7 -7
  202. package/dist/esm/core/Tag/SplitTag.js +1 -1
  203. package/dist/esm/core/Tag/style.js +5 -5
  204. package/dist/esm/core/Time/index.js +1 -1
  205. package/dist/esm/core/TimeZoneSelect/index.js +7 -7
  206. package/dist/esm/core/Timeline/Timeline.style.js +5 -5
  207. package/dist/esm/core/Token/index.js +4 -4
  208. package/dist/esm/core/Token/style.js +1 -1
  209. package/dist/esm/core/Tooltip/EllipsisTooltipContent.js +1 -1
  210. package/dist/esm/core/Tooltip/index.js +1 -1
  211. package/dist/esm/core/Truncate/index.js +1 -1
  212. package/dist/esm/core/Typo/index.js +58 -58
  213. package/dist/esm/core/WizardDialog/styles.js +4 -4
  214. package/dist/esm/coreX/BarChart/index.js +1 -1
  215. package/dist/esm/coreX/BatchOperation/index.js +2 -2
  216. package/dist/esm/coreX/ChartWithTooltip/index.js +6 -6
  217. package/dist/esm/coreX/CheckPointList/checkpointlist.style.js +3 -3
  218. package/dist/esm/coreX/CircleLoading/index.js +1 -1
  219. package/dist/esm/coreX/CronCalendar/index.js +4 -4
  220. package/dist/esm/coreX/CronPlan/index.js +4 -4
  221. package/dist/esm/coreX/DateRangePicker/DateRangePicker.style.js +12 -12
  222. package/dist/esm/coreX/DateRangePicker/RelativeTime.js +10 -7
  223. package/dist/esm/coreX/DateRangePicker/common.js +99 -6
  224. package/dist/esm/coreX/DateRangePicker/index.js +108 -48
  225. package/dist/esm/coreX/Dialogs/DeleteDialog/DeleteDialog.js +2 -2
  226. package/dist/esm/coreX/Dialogs/RejectDialog/RejectDialog.js +6 -6
  227. package/dist/esm/coreX/GoBackButton/index.js +1 -1
  228. package/dist/esm/coreX/I18nNameTag/index.js +1 -1
  229. package/dist/esm/coreX/InfoRowList/InfoRow.js +1 -1
  230. package/dist/esm/coreX/InfoRowList/InfoRowList.js +4 -4
  231. package/dist/esm/coreX/KubeConfigModal/KubeConfigModal.style.js +8 -8
  232. package/dist/esm/coreX/NamesTooltip/index.js +3 -3
  233. package/dist/esm/coreX/OverflowTooltip/index.js +4 -4
  234. package/dist/esm/coreX/Sider/index.js +3 -3
  235. package/dist/esm/coreX/SummaryTable/index.js +5 -5
  236. package/dist/esm/coreX/SwitchWithText/index.js +1 -1
  237. package/dist/esm/coreX/TabMenu/index.js +2 -2
  238. package/dist/esm/coreX/UnderlineTootip/index.js +1 -1
  239. package/dist/esm/coreX/UnitWithChart/index.js +3 -3
  240. package/dist/esm/index.js +4 -1
  241. package/dist/esm/stats1.html +1 -1
  242. package/dist/linaria.merged.scss +5086 -5060
  243. package/dist/src/core/LineChart/AreaHighlightLayer.d.ts +31 -0
  244. package/dist/src/core/LineChart/ForecastLineLayer.d.ts +24 -0
  245. package/dist/src/core/LineChart/RenderChart.d.ts +5 -1
  246. package/dist/src/core/LineChart/ThresholdIntersectionLayer.d.ts +19 -0
  247. package/dist/src/core/LineChart/TooltipFormatter.d.ts +10 -0
  248. package/dist/src/core/LineChart/__test__/AreaHighlightLayer.test.d.ts +1 -0
  249. package/dist/src/core/LineChart/__test__/ForecastLineLayer.test.d.ts +1 -0
  250. package/dist/src/core/LineChart/__test__/utils.test.d.ts +1 -0
  251. package/dist/src/core/LineChart/areaHighlightUtils.d.ts +6 -0
  252. package/dist/src/core/LineChart/lineChartDisplayUtils.d.ts +7 -0
  253. package/dist/src/core/LineChart/lineSegments.d.ts +16 -0
  254. package/dist/src/core/LineChart/styled.d.ts +2 -0
  255. package/dist/src/core/LineChart/type.d.ts +94 -8
  256. package/dist/src/core/LineChart/utils.d.ts +31 -4
  257. package/dist/src/coreX/DateRangePicker/__tests__/AbsoluteDate.test.d.ts +1 -0
  258. package/dist/src/coreX/DateRangePicker/__tests__/DateRangePicker.test.d.ts +1 -0
  259. package/dist/src/coreX/DateRangePicker/__tests__/RelativeTime.test.d.ts +1 -0
  260. package/dist/src/coreX/DateRangePicker/__tests__/common.test.d.ts +1 -0
  261. package/dist/src/coreX/DateRangePicker/common.d.ts +12 -3
  262. package/dist/src/coreX/DateRangePicker/dateRangePicker.type.d.ts +5 -1
  263. package/dist/stories/docs/core/LineChart.stories.d.ts +4 -0
  264. package/dist/stories/docs/coreX/DateRangePicker.stories.d.ts +1 -0
  265. package/dist/style.css +4515 -4491
  266. package/package.json +3 -3
@@ -0,0 +1,144 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var _ = require('lodash');
7
+ var recharts = require('recharts');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefault(React);
12
+ var ___default = /*#__PURE__*/_interopDefault(_);
13
+
14
+ const DEFAULT_THRESHOLD_LINE_STROKE = "#ff4d4f";
15
+ const DEFAULT_THRESHOLD_INTERSECTION_LABEL_TEXT_COLOR = "#ffffff";
16
+ const THRESHOLD_INTERSECTION_LABEL_HEIGHT = 28;
17
+ const THRESHOLD_INTERSECTION_LABEL_RADIUS = 4;
18
+ const THRESHOLD_INTERSECTION_LABEL_OFFSET = 8;
19
+ const THRESHOLD_INTERSECTION_LABEL_PADDING_X = 12;
20
+ const THRESHOLD_INTERSECTION_LABEL_MIN_WIDTH = 48;
21
+ const THRESHOLD_INTERSECTION_LABEL_FONT_SIZE = 12;
22
+ const THRESHOLD_INTERSECTION_CJK_REGEXP = /[\u3400-\u9fff\uf900-\ufaff]/;
23
+ const isThresholdIntersectionLabelVisible = (labelProps, info) => {
24
+ if (!labelProps) {
25
+ return false;
26
+ }
27
+ const { visible = true } = labelProps;
28
+ if (___default.default.isFunction(visible)) {
29
+ return visible(info);
30
+ }
31
+ return visible;
32
+ };
33
+ const getThresholdIntersectionLabelText = (labelProps, info) => {
34
+ const text = labelProps == null ? void 0 : labelProps.text;
35
+ if (___default.default.isFunction(text)) {
36
+ return text(info) || info.formattedThresholdValue;
37
+ }
38
+ return text || info.formattedThresholdValue;
39
+ };
40
+ const getThresholdIntersectionLabelWidth = (label) => {
41
+ const contentWidth = Array.from(label).reduce((sum, char) => {
42
+ return sum + (THRESHOLD_INTERSECTION_CJK_REGEXP.test(char) ? THRESHOLD_INTERSECTION_LABEL_FONT_SIZE : THRESHOLD_INTERSECTION_LABEL_FONT_SIZE * 0.65);
43
+ }, 0);
44
+ return Math.max(
45
+ THRESHOLD_INTERSECTION_LABEL_MIN_WIDTH,
46
+ Math.ceil(contentWidth) + THRESHOLD_INTERSECTION_LABEL_PADDING_X * 2
47
+ );
48
+ };
49
+ const ThresholdIntersectionLayer = ({
50
+ intersection,
51
+ index,
52
+ hovering,
53
+ intersectionLabelProps,
54
+ thresholdStroke,
55
+ onMouseEnter,
56
+ onMouseLeave,
57
+ xAxisMap,
58
+ yAxisMap
59
+ }) => {
60
+ const xAxis = xAxisMap == null ? void 0 : xAxisMap[0];
61
+ const yAxis = yAxisMap == null ? void 0 : yAxisMap[0];
62
+ if (typeof (xAxis == null ? void 0 : xAxis.scale) !== "function" || typeof (yAxis == null ? void 0 : yAxis.scale) !== "function") {
63
+ return null;
64
+ }
65
+ return /* @__PURE__ */ React__default.default.createElement(
66
+ recharts.ReferenceDot,
67
+ {
68
+ xAxis,
69
+ yAxis,
70
+ x: intersection.timestamp,
71
+ y: intersection.value,
72
+ isFront: true,
73
+ shape: (shapeProps) => {
74
+ const { cx = 0, cy = 0 } = shapeProps;
75
+ const intersectionOpacity = hovering.includes(intersection.legend.id) ? 0.3 : 1;
76
+ const showIntersectionLabel = isThresholdIntersectionLabelVisible(
77
+ intersectionLabelProps,
78
+ intersection
79
+ );
80
+ const intersectionLabelText = showIntersectionLabel ? getThresholdIntersectionLabelText(
81
+ intersectionLabelProps,
82
+ intersection
83
+ ) : "";
84
+ const intersectionLabelColor = (intersectionLabelProps == null ? void 0 : intersectionLabelProps.color) || thresholdStroke || DEFAULT_THRESHOLD_LINE_STROKE;
85
+ const intersectionLabelTextColor = (intersectionLabelProps == null ? void 0 : intersectionLabelProps.textColor) || DEFAULT_THRESHOLD_INTERSECTION_LABEL_TEXT_COLOR;
86
+ const intersectionLabelWidth = getThresholdIntersectionLabelWidth(
87
+ intersectionLabelText
88
+ );
89
+ const intersectionLabelX = cx - intersectionLabelWidth / 2;
90
+ const intersectionLabelY = cy - THRESHOLD_INTERSECTION_LABEL_HEIGHT - THRESHOLD_INTERSECTION_LABEL_OFFSET;
91
+ return /* @__PURE__ */ React__default.default.createElement(
92
+ "g",
93
+ {
94
+ "data-testid": "line-chart-threshold-intersection-dot",
95
+ "data-intersection-id": `${intersection.legend.id}-${index}`,
96
+ onMouseEnter: () => onMouseEnter(intersection, cx, cy),
97
+ onMouseLeave
98
+ },
99
+ /* @__PURE__ */ React__default.default.createElement(
100
+ "circle",
101
+ {
102
+ cx,
103
+ cy,
104
+ r: 8,
105
+ fill: "transparent",
106
+ stroke: "transparent"
107
+ }
108
+ ),
109
+ showIntersectionLabel && /* @__PURE__ */ React__default.default.createElement("g", { "data-testid": "line-chart-threshold-intersection-label" }, /* @__PURE__ */ React__default.default.createElement(
110
+ "rect",
111
+ {
112
+ "data-testid": "line-chart-threshold-intersection-label-background",
113
+ x: intersectionLabelX,
114
+ y: intersectionLabelY,
115
+ width: intersectionLabelWidth,
116
+ height: THRESHOLD_INTERSECTION_LABEL_HEIGHT,
117
+ rx: THRESHOLD_INTERSECTION_LABEL_RADIUS,
118
+ ry: THRESHOLD_INTERSECTION_LABEL_RADIUS,
119
+ fill: intersectionLabelColor,
120
+ opacity: intersectionOpacity
121
+ }
122
+ ), /* @__PURE__ */ React__default.default.createElement(
123
+ "text",
124
+ {
125
+ x: cx,
126
+ y: intersectionLabelY + THRESHOLD_INTERSECTION_LABEL_HEIGHT / 2,
127
+ fill: intersectionLabelTextColor,
128
+ fontSize: THRESHOLD_INTERSECTION_LABEL_FONT_SIZE,
129
+ fontWeight: 500,
130
+ textAnchor: "middle",
131
+ dominantBaseline: "middle",
132
+ opacity: intersectionOpacity
133
+ },
134
+ intersectionLabelText
135
+ ))
136
+ );
137
+ }
138
+ }
139
+ );
140
+ };
141
+ var ThresholdIntersectionLayer$1 = ThresholdIntersectionLayer;
142
+
143
+ exports.default = ThresholdIntersectionLayer$1;
144
+ exports.isThresholdIntersectionLabelVisible = isThresholdIntersectionLabelVisible;
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  var react = require('@linaria/react');
4
6
  var LineChartLegend = require('./LineChartLegend.js');
5
7
  var styled = require('./styled.js');
8
+ var utils = require('./utils.js');
6
9
  var dayjs = require('dayjs');
7
10
  var React = require('react');
8
11
  var index = require('../Typo/index.js');
@@ -12,32 +15,30 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
12
15
  var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
13
16
  var React__default = /*#__PURE__*/_interopDefault(React);
14
17
 
15
- var __defProp = Object.defineProperty;
16
- var __defProps = Object.defineProperties;
17
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
18
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
19
- var __hasOwnProp = Object.prototype.hasOwnProperty;
20
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
21
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
22
- enumerable: true,
23
- configurable: true,
24
- writable: true,
25
- value
26
- }) : obj[key] = value;
27
- var __spreadValues = (a, b) => {
28
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
29
- if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
30
- if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
31
- }
32
- return a;
33
- };
34
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
35
18
  const TooltipTitle = /*#__PURE__*/react.styled('div')({
36
19
  name: "TooltipTitle",
37
- class: "E_4100_0_18_t1616y1o",
20
+ class: "E_4100_0_19_t1616y1o",
38
21
  propsAsIs: false
39
22
  });
23
+ const LineChartTooltipContent = ({
24
+ title,
25
+ items
26
+ }) => {
27
+ return /* @__PURE__ */React__default.default.createElement(styled.TooltipWrapper, null, /* @__PURE__ */React__default.default.createElement(TooltipTitle, {
28
+ className: index.Typo.Label.l4_bold_title
29
+ }, title), items.map(item => {
30
+ return /* @__PURE__ */React__default.default.createElement(styled.TooltipColumn, {
31
+ key: item.id
32
+ }, /* @__PURE__ */React__default.default.createElement("div", null, /* @__PURE__ */React__default.default.createElement(LineChartLegend.LineChartColorBlock, {
33
+ background: item.color,
34
+ borderd: true
35
+ }), item.label), /* @__PURE__ */React__default.default.createElement("div", {
36
+ className: "column-value"
37
+ }, item.value));
38
+ }));
39
+ };
40
40
  const TooltipFormatter = props => {
41
+ var _a, _b;
41
42
  const {
42
43
  active,
43
44
  payload,
@@ -48,24 +49,28 @@ const TooltipFormatter = props => {
48
49
  if (!active || !(payload == null ? void 0 : payload.length)) {
49
50
  return null;
50
51
  }
51
- return /* @__PURE__ */React__default.default.createElement(styled.TooltipWrapper, null, /* @__PURE__ */React__default.default.createElement(TooltipTitle, {
52
- className: index.Typo.Label.l4_bold_title
53
- }, dayjs__default.default(Number(payload[0].payload.t)).format("MM/DD HH:mm:ss")), payload.map(item => {
54
- return __spreadProps(__spreadValues({}, item), {
55
- legend: legends.find((_legend, index) => `v${index}` === item.name)
56
- });
57
- }).sort((a, b) => b.value - a.value).map(item => {
58
- var _a, _b, _c, _d;
59
- return deselected.includes(((_a = item.legend) == null ? void 0 : _a.id) || "") ? null : /* @__PURE__ */React__default.default.createElement(styled.TooltipColumn, {
60
- key: (_b = item.legend) == null ? void 0 : _b.id
61
- }, /* @__PURE__ */React__default.default.createElement("div", null, /* @__PURE__ */React__default.default.createElement(LineChartLegend.LineChartColorBlock, {
62
- background: (_c = item.legend) == null ? void 0 : _c.color,
63
- borderd: true
64
- }), (_d = item.legend) == null ? void 0 : _d.name), /* @__PURE__ */React__default.default.createElement("div", {
65
- className: "column-value"
66
- }, format(item)));
67
- }));
52
+ const metricPayloads = utils.getLineChartMetricPayloadMatches(payload, legends);
53
+ const titlePayload = (_b = (_a = metricPayloads[0]) == null ? void 0 : _a.payload) == null ? void 0 : _b.payload;
54
+ if (!titlePayload) {
55
+ return null;
56
+ }
57
+ const items = metricPayloads.sort((a, b) => b.payload.value - a.payload.value).flatMap(item => {
58
+ if (deselected.includes(item.legend.id)) {
59
+ return [];
60
+ }
61
+ return [{
62
+ id: item.legend.id,
63
+ color: item.legend.color,
64
+ label: item.legend.name,
65
+ value: format(item.payload)
66
+ }];
67
+ });
68
+ return /* @__PURE__ */React__default.default.createElement(LineChartTooltipContent, {
69
+ title: dayjs__default.default(Number(titlePayload.t)).format("MM/DD HH:mm:ss"),
70
+ items
71
+ });
68
72
  };
69
73
  var TooltipFormatter$1 = TooltipFormatter;
70
74
 
71
- module.exports = TooltipFormatter$1;
75
+ exports.LineChartTooltipContent = LineChartTooltipContent;
76
+ exports.default = TooltipFormatter$1;
@@ -0,0 +1,89 @@
1
+ 'use strict';
2
+
3
+ const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
4
+ const getLineChartInterpolatedValue = (currentPoint, nextPoint, timestamp) => {
5
+ if (!isFiniteNumber(currentPoint.v) || !isFiniteNumber(nextPoint.v) || currentPoint.t === nextPoint.t) {
6
+ return void 0;
7
+ }
8
+ if (timestamp === currentPoint.t) {
9
+ return currentPoint.v;
10
+ }
11
+ if (timestamp === nextPoint.t) {
12
+ return nextPoint.v;
13
+ }
14
+ const ratio = (timestamp - currentPoint.t) / (nextPoint.t - currentPoint.t);
15
+ return currentPoint.v + (nextPoint.v - currentPoint.v) * ratio;
16
+ };
17
+ const isSameAreaHighlightPoint = (prev, next) => {
18
+ if (!prev) {
19
+ return false;
20
+ }
21
+ return Math.abs(prev.t - next.t) < 1e-6 && Math.abs(prev.value - next.value) < 1e-6;
22
+ };
23
+ const pushLineChartAreaHighlightPoint = (points, next) => {
24
+ if (!isSameAreaHighlightPoint(points[points.length - 1], next)) {
25
+ points.push(next);
26
+ }
27
+ };
28
+ const getLineChartAreaHighlightPointRuns = (points, range) => {
29
+ const runs = [];
30
+ let highlightedPoints = [];
31
+ const flushHighlightedPoints = () => {
32
+ if (highlightedPoints.length >= 2) {
33
+ runs.push(highlightedPoints);
34
+ }
35
+ highlightedPoints = [];
36
+ };
37
+ for (let index = 0; index < points.length - 1; index++) {
38
+ const currentPoint = points[index];
39
+ const nextPoint = points[index + 1];
40
+ if (!isFiniteNumber(currentPoint == null ? void 0 : currentPoint.t) || !isFiniteNumber(nextPoint == null ? void 0 : nextPoint.t) || !isFiniteNumber(currentPoint == null ? void 0 : currentPoint.v) || !isFiniteNumber(nextPoint == null ? void 0 : nextPoint.v) || currentPoint.t === nextPoint.t) {
41
+ flushHighlightedPoints();
42
+ continue;
43
+ }
44
+ if (nextPoint.t < range.start || currentPoint.t > range.end) {
45
+ continue;
46
+ }
47
+ const segmentStart = Math.max(range.start, currentPoint.t);
48
+ const segmentEnd = Math.min(range.end, nextPoint.t);
49
+ if (segmentStart >= segmentEnd) {
50
+ continue;
51
+ }
52
+ const startValue = getLineChartInterpolatedValue(
53
+ currentPoint,
54
+ nextPoint,
55
+ segmentStart
56
+ );
57
+ const endValue = getLineChartInterpolatedValue(
58
+ currentPoint,
59
+ nextPoint,
60
+ segmentEnd
61
+ );
62
+ if (!isFiniteNumber(startValue) || !isFiniteNumber(endValue)) {
63
+ flushHighlightedPoints();
64
+ continue;
65
+ }
66
+ const startPoint = {
67
+ t: segmentStart,
68
+ value: startValue
69
+ };
70
+ const endPoint = {
71
+ t: segmentEnd,
72
+ value: endValue
73
+ };
74
+ if (highlightedPoints.length && isSameAreaHighlightPoint(
75
+ highlightedPoints[highlightedPoints.length - 1],
76
+ startPoint
77
+ )) {
78
+ pushLineChartAreaHighlightPoint(highlightedPoints, endPoint);
79
+ } else {
80
+ flushHighlightedPoints();
81
+ highlightedPoints = [startPoint, endPoint];
82
+ }
83
+ }
84
+ flushHighlightedPoints();
85
+ return runs;
86
+ };
87
+ const getLineChartAreaHighlightRuns = (points, range) => getLineChartAreaHighlightPointRuns(points, range);
88
+
89
+ exports.getLineChartAreaHighlightRuns = getLineChartAreaHighlightRuns;
@@ -7,6 +7,7 @@ var index = require('../ErrorBoundary/index.js');
7
7
  var Pointer = require('./Pointer.js');
8
8
  var RenderChart = require('./RenderChart.js');
9
9
  var styled = require('./styled.js');
10
+ var useElementResize = require('../../hooks/useElementResize.js');
10
11
  var cs = require('classnames');
11
12
  var React = require('react');
12
13
 
@@ -46,15 +47,32 @@ const LineChart = React__default.default.forwardRef(
46
47
  } = props;
47
48
  const [width, setWidth] = React.useState(0);
48
49
  const wrapperRef = React.useRef(null);
49
- React.useEffect(() => {
50
+ const syncWrapperWidth = React.useCallback(() => {
50
51
  var _a;
51
52
  setWidth(((_a = wrapperRef.current) == null ? void 0 : _a.offsetWidth) || 0);
52
53
  }, []);
54
+ const setWrapperNode = React.useCallback(
55
+ (node) => {
56
+ wrapperRef.current = node;
57
+ if (typeof ref === "function") {
58
+ ref(node);
59
+ return;
60
+ }
61
+ if (ref) {
62
+ ref.current = node;
63
+ }
64
+ },
65
+ [ref]
66
+ );
67
+ React.useEffect(() => {
68
+ syncWrapperWidth();
69
+ }, [syncWrapperWidth]);
70
+ useElementResize(wrapperRef, syncWrapperWidth, [showLegend, showXaxis, height]);
53
71
  return /* @__PURE__ */ React__default.default.createElement(index, { i18n: parrot.parrotI18n }, /* @__PURE__ */ React__default.default.createElement(
54
72
  styled.LineChartWrapper,
55
73
  {
56
74
  className: cs__default.default("metric-wrapper", !showXaxis && "hidden-xaxis"),
57
- ref: wrapperRef,
75
+ ref: setWrapperNode,
58
76
  "data-testid": dataTestId,
59
77
  style: { height: showLegend ? height + 30 : height }
60
78
  },
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ const DEFAULT_LINE_CHART_STROKE = "#3182bd";
4
+ const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
5
+ const isFiniteNumericYAxisDomain = (domain) => {
6
+ if (!Array.isArray(domain) || domain.length !== 2) {
7
+ return false;
8
+ }
9
+ return isFiniteNumber(domain[0]) && isFiniteNumber(domain[1]);
10
+ };
11
+ const getLineChartStreamStroke = (stream) => {
12
+ var _a;
13
+ const color = (_a = stream.legend.color) != null ? _a : DEFAULT_LINE_CHART_STROKE;
14
+ return stream.legend.stroke ? `${color}1A` : color;
15
+ };
16
+ const getLineChartDefaultYAxisTicks = (domain) => {
17
+ if (!isFiniteNumericYAxisDomain(domain)) {
18
+ return void 0;
19
+ }
20
+ const [, upper] = domain;
21
+ return [upper / 2, upper];
22
+ };
23
+ const getLineChartLegacyThresholdTooltipInfo = (info) => ({
24
+ current: info.formattedValue,
25
+ max: info.formattedThresholdValue
26
+ });
27
+
28
+ exports.DEFAULT_LINE_CHART_STROKE = DEFAULT_LINE_CHART_STROKE;
29
+ exports.getLineChartDefaultYAxisTicks = getLineChartDefaultYAxisTicks;
30
+ exports.getLineChartLegacyThresholdTooltipInfo = getLineChartLegacyThresholdTooltipInfo;
31
+ exports.getLineChartStreamStroke = getLineChartStreamStroke;
32
+ exports.isFiniteNumber = isFiniteNumber;
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ const isFiniteNumber = (value) => typeof value === "number" && Number.isFinite(value);
4
+ const getLineChartLinePoint = (point) => {
5
+ if (!isFiniteNumber(point.t) || !isFiniteNumber(point.x) || !isFiniteNumber(point.y)) {
6
+ return void 0;
7
+ }
8
+ return {
9
+ t: point.t,
10
+ x: point.x,
11
+ y: point.y
12
+ };
13
+ };
14
+ const getLineChartBoundaryPoint = (previous, next, timestamp) => {
15
+ const duration = next.t - previous.t;
16
+ if (!duration) {
17
+ return void 0;
18
+ }
19
+ const ratio = (timestamp - previous.t) / duration;
20
+ return {
21
+ t: timestamp,
22
+ x: previous.x + (next.x - previous.x) * ratio,
23
+ y: previous.y + (next.y - previous.y) * ratio
24
+ };
25
+ };
26
+ const getLineChartLineSegments = (points, forecastStartTimestamp) => {
27
+ const segments = [];
28
+ const hasForecastStart = isFiniteNumber(forecastStartTimestamp);
29
+ let continuousPoints = [];
30
+ const flushContinuousPoints = () => {
31
+ if (continuousPoints.length < 2) {
32
+ continuousPoints = [];
33
+ return;
34
+ }
35
+ let segmentPoints = [continuousPoints[0]];
36
+ let dashed = Boolean(
37
+ hasForecastStart && continuousPoints[0].t >= forecastStartTimestamp
38
+ );
39
+ const pushSegment = () => {
40
+ if (segmentPoints.length >= 2) {
41
+ segments.push({ dashed, points: segmentPoints });
42
+ }
43
+ };
44
+ for (let index = 1; index < continuousPoints.length; index += 1) {
45
+ const previous = continuousPoints[index - 1];
46
+ const next = continuousPoints[index];
47
+ const nextDashed = Boolean(
48
+ hasForecastStart && next.t >= forecastStartTimestamp
49
+ );
50
+ if (hasForecastStart && nextDashed !== dashed) {
51
+ const boundaryPoint = getLineChartBoundaryPoint(
52
+ previous,
53
+ next,
54
+ forecastStartTimestamp
55
+ );
56
+ if (boundaryPoint) {
57
+ segmentPoints.push(boundaryPoint);
58
+ pushSegment();
59
+ segmentPoints = [boundaryPoint];
60
+ if (boundaryPoint.t !== next.t) {
61
+ segmentPoints.push(next);
62
+ }
63
+ dashed = nextDashed;
64
+ continue;
65
+ }
66
+ }
67
+ segmentPoints.push(next);
68
+ }
69
+ pushSegment();
70
+ continuousPoints = [];
71
+ };
72
+ points.forEach((point) => {
73
+ const linePoint = getLineChartLinePoint(point);
74
+ if (!linePoint) {
75
+ flushContinuousPoints();
76
+ return;
77
+ }
78
+ continuousPoints.push(linePoint);
79
+ });
80
+ flushContinuousPoints();
81
+ return segments;
82
+ };
83
+ const getLineChartLinePath = (points) => {
84
+ return points.map((point, index) => {
85
+ return `${index === 0 ? "M" : "L"}${point.x},${point.y}`;
86
+ }).join(" ");
87
+ };
88
+
89
+ exports.getLineChartLinePath = getLineChartLinePath;
90
+ exports.getLineChartLineSegments = getLineChartLineSegments;
@@ -2,28 +2,39 @@
2
2
 
3
3
  var react = require('@linaria/react');
4
4
 
5
- const MetricLegendTabStyle = "E_4100_0_18_mn7joto";
6
- const LegendStyle = "E_4100_0_18_l1bifhon";
7
- const LegendItemsStyle = "E_4100_0_18_ltthzck";
8
- const LegendItemsStyleDropdown = "E_4100_0_18_l1mumj7o";
9
- const ExtraResource = "E_4100_0_18_e45tc5l";
5
+ const MetricLegendTabStyle = "E_4100_0_19_mn7joto";
6
+ const LegendStyle = "E_4100_0_19_l1bifhon";
7
+ const LegendItemsStyle = "E_4100_0_19_ltthzck";
8
+ const LegendItemsStyleDropdown = "E_4100_0_19_l1mumj7o";
9
+ const ExtraResource = "E_4100_0_19_e45tc5l";
10
10
  const LineChartWrapper = /*#__PURE__*/react.styled('div')({
11
11
  name: "LineChartWrapper",
12
- class: "E_4100_0_18_lqeaosa",
12
+ class: "E_4100_0_19_lqeaosa",
13
+ propsAsIs: false
14
+ });
15
+ const ChartContentWrapper = /*#__PURE__*/react.styled('div')({
16
+ name: "ChartContentWrapper",
17
+ class: "E_4100_0_19_c2pr38p",
18
+ propsAsIs: false
19
+ });
20
+ const ThresholdTooltipOverlay = /*#__PURE__*/react.styled('div')({
21
+ name: "ThresholdTooltipOverlay",
22
+ class: "E_4100_0_19_tecdsj7",
13
23
  propsAsIs: false
14
24
  });
15
25
  const TooltipWrapper = /*#__PURE__*/react.styled('div')({
16
26
  name: "TooltipWrapper",
17
- class: "E_4100_0_18_t2pr38p",
27
+ class: "E_4100_0_19_tjhvvia",
18
28
  propsAsIs: false
19
29
  });
20
30
  const TooltipColumn = /*#__PURE__*/react.styled('div')({
21
31
  name: "TooltipColumn",
22
- class: "E_4100_0_18_tecdsj7",
32
+ class: "E_4100_0_19_tuyrup3",
23
33
  propsAsIs: false
24
34
  });
25
- const LineChartColorBlockStyle = "E_4100_0_18_ljhvvia";
35
+ const LineChartColorBlockStyle = "E_4100_0_19_lheyn3m";
26
36
 
37
+ exports.ChartContentWrapper = ChartContentWrapper;
27
38
  exports.ExtraResource = ExtraResource;
28
39
  exports.LegendItemsStyle = LegendItemsStyle;
29
40
  exports.LegendItemsStyleDropdown = LegendItemsStyleDropdown;
@@ -31,5 +42,6 @@ exports.LegendStyle = LegendStyle;
31
42
  exports.LineChartColorBlockStyle = LineChartColorBlockStyle;
32
43
  exports.LineChartWrapper = LineChartWrapper;
33
44
  exports.MetricLegendTabStyle = MetricLegendTabStyle;
45
+ exports.ThresholdTooltipOverlay = ThresholdTooltipOverlay;
34
46
  exports.TooltipColumn = TooltipColumn;
35
47
  exports.TooltipWrapper = TooltipWrapper;