@perses-dev/components 0.8.1 → 0.10.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 (131) hide show
  1. package/dist/Drawer/Drawer.d.ts +3 -4
  2. package/dist/Drawer/Drawer.d.ts.map +1 -1
  3. package/dist/Drawer/Drawer.js +35 -1
  4. package/dist/Drawer/Drawer.js.map +1 -0
  5. package/dist/Drawer/index.js +15 -1
  6. package/dist/Drawer/index.js.map +1 -0
  7. package/dist/EChart.d.ts.map +1 -1
  8. package/dist/EChart.js +142 -1
  9. package/dist/EChart.js.map +1 -0
  10. package/dist/ErrorAlert.js +25 -1
  11. package/dist/ErrorAlert.js.map +1 -0
  12. package/dist/ErrorBoundary.js +16 -1
  13. package/dist/ErrorBoundary.js.map +1 -0
  14. package/dist/GaugeChart/GaugeChart.js +172 -1
  15. package/dist/GaugeChart/GaugeChart.js.map +1 -0
  16. package/dist/GaugeChart/index.js +15 -1
  17. package/dist/GaugeChart/index.js.map +1 -0
  18. package/dist/InfoTooltip/InfoTooltip.js +79 -1
  19. package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
  20. package/dist/InfoTooltip/InfoTooltip.test.js +36 -1
  21. package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
  22. package/dist/InfoTooltip/index.js +15 -1
  23. package/dist/InfoTooltip/index.js.map +1 -0
  24. package/dist/LineChart/LineChart.js +198 -1
  25. package/dist/LineChart/LineChart.js.map +1 -0
  26. package/dist/LineChart/index.js +15 -1
  27. package/dist/LineChart/index.js.map +1 -0
  28. package/dist/LineChart/utils.js +63 -1
  29. package/dist/LineChart/utils.js.map +1 -0
  30. package/dist/StatChart/StatChart.js +121 -1
  31. package/dist/StatChart/StatChart.js.map +1 -0
  32. package/dist/StatChart/StatChart.test.js +82 -1
  33. package/dist/StatChart/StatChart.test.js.map +1 -0
  34. package/dist/StatChart/index.js +15 -1
  35. package/dist/StatChart/index.js.map +1 -0
  36. package/dist/TimeRangeSelector/AbsoluteTimePicker.js +175 -1
  37. package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +1 -0
  38. package/dist/TimeRangeSelector/TimeRangeSelector.js +52 -1
  39. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
  40. package/dist/TimeRangeSelector/index.js +16 -1
  41. package/dist/TimeRangeSelector/index.js.map +1 -0
  42. package/dist/TimeRangeSelector/utils.js +36 -1
  43. package/dist/TimeRangeSelector/utils.js.map +1 -0
  44. package/dist/Tooltip/SeriesInfo.js +143 -1
  45. package/dist/Tooltip/SeriesInfo.js.map +1 -0
  46. package/dist/Tooltip/SeriesMarker.js +33 -1
  47. package/dist/Tooltip/SeriesMarker.js.map +1 -0
  48. package/dist/Tooltip/Tooltip.js +72 -1
  49. package/dist/Tooltip/Tooltip.js.map +1 -0
  50. package/dist/Tooltip/TooltipContent.js +89 -1
  51. package/dist/Tooltip/TooltipContent.js.map +1 -0
  52. package/dist/Tooltip/focused-series.js +108 -1
  53. package/dist/Tooltip/focused-series.js.map +1 -0
  54. package/dist/Tooltip/focused-series.test.js +75 -1
  55. package/dist/Tooltip/focused-series.test.js.map +1 -0
  56. package/dist/Tooltip/index.js +16 -1
  57. package/dist/Tooltip/index.js.map +1 -0
  58. package/dist/Tooltip/tooltip-model.js +80 -1
  59. package/dist/Tooltip/tooltip-model.js.map +1 -0
  60. package/dist/Tooltip/utils.js +46 -1
  61. package/dist/Tooltip/utils.js.map +1 -0
  62. package/dist/cjs/Drawer/Drawer.js +26 -13
  63. package/dist/cjs/Drawer/index.js +16 -17
  64. package/dist/cjs/EChart.js +114 -89
  65. package/dist/cjs/ErrorAlert.js +16 -12
  66. package/dist/cjs/ErrorBoundary.js +10 -6
  67. package/dist/cjs/GaugeChart/GaugeChart.js +90 -57
  68. package/dist/cjs/GaugeChart/index.js +16 -17
  69. package/dist/cjs/InfoTooltip/InfoTooltip.js +90 -33
  70. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +27 -17
  71. package/dist/cjs/InfoTooltip/index.js +16 -17
  72. package/dist/cjs/LineChart/LineChart.js +122 -87
  73. package/dist/cjs/LineChart/index.js +16 -17
  74. package/dist/cjs/LineChart/utils.js +23 -23
  75. package/dist/cjs/StatChart/StatChart.js +107 -46
  76. package/dist/cjs/StatChart/StatChart.test.js +65 -21
  77. package/dist/cjs/StatChart/index.js +16 -17
  78. package/dist/cjs/TimeRangeSelector/AbsoluteTimePicker.js +144 -64
  79. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +45 -22
  80. package/dist/cjs/TimeRangeSelector/index.js +17 -18
  81. package/dist/cjs/TimeRangeSelector/utils.js +19 -16
  82. package/dist/cjs/Tooltip/SeriesInfo.js +120 -48
  83. package/dist/cjs/Tooltip/SeriesMarker.js +20 -11
  84. package/dist/cjs/Tooltip/Tooltip.js +95 -67
  85. package/dist/cjs/Tooltip/TooltipContent.js +76 -31
  86. package/dist/cjs/Tooltip/focused-series.js +40 -36
  87. package/dist/cjs/Tooltip/focused-series.test.js +36 -16
  88. package/dist/cjs/Tooltip/index.js +17 -18
  89. package/dist/cjs/Tooltip/tooltip-model.js +46 -30
  90. package/dist/cjs/Tooltip/utils.js +13 -16
  91. package/dist/cjs/context/ChartsThemeProvider.js +65 -13
  92. package/dist/cjs/index.js +27 -28
  93. package/dist/cjs/model/graph.js +10 -5
  94. package/dist/cjs/model/index.js +18 -19
  95. package/dist/cjs/model/theme.js +4 -2
  96. package/dist/cjs/model/units.js +68 -51
  97. package/dist/cjs/test/index.js +16 -17
  98. package/dist/cjs/test/render.js +22 -12
  99. package/dist/cjs/test/setup-tests.js +4 -2
  100. package/dist/cjs/utils/combine-sx.js +15 -16
  101. package/dist/cjs/utils/index.js +17 -18
  102. package/dist/cjs/utils/theme-gen.js +64 -55
  103. package/dist/cjs/utils/theme-gen.test.js +14 -12
  104. package/dist/context/ChartsThemeProvider.js +36 -1
  105. package/dist/context/ChartsThemeProvider.js.map +1 -0
  106. package/dist/index.js +26 -1
  107. package/dist/index.js.map +1 -0
  108. package/dist/model/graph.js +15 -1
  109. package/dist/model/graph.js.map +1 -0
  110. package/dist/model/index.js +17 -1
  111. package/dist/model/index.js.map +1 -0
  112. package/dist/model/theme.js +15 -1
  113. package/dist/model/theme.js.map +1 -0
  114. package/dist/model/units.d.ts.map +1 -1
  115. package/dist/model/units.js +196 -1
  116. package/dist/model/units.js.map +1 -0
  117. package/dist/test/index.js +15 -1
  118. package/dist/test/index.js.map +1 -0
  119. package/dist/test/render.js +32 -1
  120. package/dist/test/render.js.map +1 -0
  121. package/dist/test/setup-tests.js +18 -1
  122. package/dist/test/setup-tests.js.map +1 -0
  123. package/dist/utils/combine-sx.js +27 -1
  124. package/dist/utils/combine-sx.js.map +1 -0
  125. package/dist/utils/index.js +16 -1
  126. package/dist/utils/index.js.map +1 -0
  127. package/dist/utils/theme-gen.js +183 -1
  128. package/dist/utils/theme-gen.js.map +1 -0
  129. package/dist/utils/theme-gen.test.js +196 -1
  130. package/dist/utils/theme-gen.test.js.map +1 -0
  131. package/package.json +8 -4
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SeriesInfo = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- // Copyright 2021 The Perses Authors
1
+ // Copyright 2022 The Perses Authors
6
2
  // Licensed under the Apache License, Version 2.0 (the "License");
7
3
  // you may not use this file except in compliance with the License.
8
4
  // You may obtain a copy of the License at
@@ -14,64 +10,140 @@ const jsx_runtime_1 = require("react/jsx-runtime");
14
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
11
  // See the License for the specific language governing permissions and
16
12
  // limitations under the License.
17
- const material_1 = require("@mui/material");
18
- const SeriesMarker_1 = require("./SeriesMarker");
19
- const tooltip_model_1 = require("./tooltip-model");
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "SeriesInfo", {
18
+ enumerable: true,
19
+ get: ()=>SeriesInfo
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _seriesMarker = require("./SeriesMarker");
24
+ const _tooltipModel = require("./tooltip-model");
20
25
  function SeriesInfo(props) {
21
- const { seriesName, y, markerColor, totalSeries, wrapLabels } = props;
26
+ const { seriesName , y , markerColor , totalSeries , wrapLabels } = props;
22
27
  // TODO (sjcobb): regex to remove __name__, improve series labels
23
28
  const formattedSeriesLabels = seriesName.replace(/[{}"]/g, '');
24
29
  if (totalSeries === 1) {
25
30
  const jsonFormattedSeries = seriesName[0] === '{' ? true : false;
26
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { spacing: 0.5, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: (theme) => ({
27
- height: '16px',
28
- display: 'flex',
29
- flexDirection: 'row',
30
- alignItems: 'center',
31
- justifyContent: 'left',
32
- color: theme.palette.common.white,
33
- fontSize: '11px',
34
- }), children: [(0, jsx_runtime_1.jsx)(SeriesMarker_1.SeriesMarker, { markerColor: markerColor }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "span", children: ["value:", (0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: (theme) => ({
35
- color: theme.palette.common.white,
36
- fontWeight: 700,
37
- paddingLeft: '2px',
38
- }), children: y })] })] }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: (theme) => ({
39
- borderColor: theme.palette.grey['500'],
40
- }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: (theme) => ({
41
- color: theme.palette.common.white,
42
- }), children: formattedSeriesLabels.split(',').map((name) => {
31
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
32
+ spacing: 0.5,
33
+ children: [
34
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
35
+ sx: (theme)=>({
36
+ height: '16px',
37
+ display: 'flex',
38
+ flexDirection: 'row',
39
+ alignItems: 'center',
40
+ justifyContent: 'left',
41
+ color: theme.palette.common.white,
42
+ fontSize: '11px'
43
+ }),
44
+ children: [
45
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesMarker.SeriesMarker, {
46
+ markerColor: markerColor
47
+ }),
48
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
49
+ component: "span",
50
+ children: [
51
+ "value:",
52
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
53
+ component: "span",
54
+ sx: (theme)=>({
55
+ color: theme.palette.common.white,
56
+ fontWeight: 700,
57
+ paddingLeft: '2px'
58
+ }),
59
+ children: y
60
+ })
61
+ ]
62
+ })
63
+ ]
64
+ }),
65
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
66
+ sx: (theme)=>({
67
+ borderColor: theme.palette.grey['500']
68
+ })
69
+ }),
70
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
71
+ sx: (theme)=>({
72
+ color: theme.palette.common.white
73
+ }),
74
+ children: formattedSeriesLabels.split(',').map((name)=>{
43
75
  if (name) {
44
76
  const [key, value] = jsonFormattedSeries ? name.split(':') : name.split('=');
45
77
  const formattedKey = value !== undefined ? `${key}: ` : key;
46
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: 'flex', gap: '4px' }, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { sx: { fontSize: '11px' }, children: formattedKey }), (0, jsx_runtime_1.jsx)(material_1.Typography, { sx: (theme) => ({
47
- color: theme.palette.common.white,
48
- fontWeight: 700,
49
- fontSize: '11px',
50
- }), children: value })] }, name));
78
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
79
+ sx: {
80
+ display: 'flex',
81
+ gap: '4px'
82
+ },
83
+ children: [
84
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
85
+ sx: {
86
+ fontSize: '11px'
87
+ },
88
+ children: formattedKey
89
+ }),
90
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
91
+ sx: (theme)=>({
92
+ color: theme.palette.common.white,
93
+ fontWeight: 700,
94
+ fontSize: '11px'
95
+ }),
96
+ children: value
97
+ })
98
+ ]
99
+ }, name);
51
100
  }
52
- }) })] }));
101
+ })
102
+ })
103
+ ]
104
+ });
53
105
  }
54
106
  const inlineSeriesLabels = formattedSeriesLabels.replace(/[,]/g, ', ').replace(/[:=]/g, ': ');
55
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
107
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
108
+ sx: {
56
109
  display: 'table-row',
57
- paddingTop: 0.5,
58
- }, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
110
+ paddingTop: 0.5
111
+ },
112
+ children: [
113
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
114
+ sx: {
59
115
  display: 'table-cell',
60
- maxWidth: '520px',
61
- }, children: [(0, jsx_runtime_1.jsx)(SeriesMarker_1.SeriesMarker, { markerColor: markerColor }), (0, jsx_runtime_1.jsx)(material_1.Box, { component: "span", sx: (theme) => ({
62
- color: theme.palette.common.white,
63
- display: 'inline-block',
64
- maxWidth: tooltip_model_1.TOOLTIP_LABELS_MAX_WIDTH,
65
- overflow: 'hidden',
66
- textOverflow: 'ellipsis',
67
- whiteSpace: wrapLabels ? 'normal' : 'nowrap',
68
- width: 'calc(100% - 20px)',
69
- }), children: inlineSeriesLabels })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
116
+ maxWidth: '520px'
117
+ },
118
+ children: [
119
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesMarker.SeriesMarker, {
120
+ markerColor: markerColor
121
+ }),
122
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
123
+ component: "span",
124
+ sx: (theme)=>({
125
+ color: theme.palette.common.white,
126
+ display: 'inline-block',
127
+ maxWidth: _tooltipModel.TOOLTIP_LABELS_MAX_WIDTH,
128
+ overflow: 'hidden',
129
+ textOverflow: 'ellipsis',
130
+ whiteSpace: wrapLabels ? 'normal' : 'nowrap',
131
+ width: 'calc(100% - 20px)'
132
+ }),
133
+ children: inlineSeriesLabels
134
+ })
135
+ ]
136
+ }),
137
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
138
+ sx: {
70
139
  display: 'table-cell',
71
140
  fontWeight: '700',
72
141
  paddingLeft: 1.5,
73
142
  textAlign: 'right',
74
- verticalAlign: 'top',
75
- }, children: y })] }));
143
+ verticalAlign: 'top'
144
+ },
145
+ children: y
146
+ })
147
+ ]
148
+ });
76
149
  }
77
- exports.SeriesInfo = SeriesInfo;
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SeriesMarker = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- // Copyright 2021 The Perses Authors
1
+ // Copyright 2022 The Perses Authors
6
2
  // Licensed under the Apache License, Version 2.0 (the "License");
7
3
  // you may not use this file except in compliance with the License.
8
4
  // You may obtain a copy of the License at
@@ -14,17 +10,30 @@ const jsx_runtime_1 = require("react/jsx-runtime");
14
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
11
  // See the License for the specific language governing permissions and
16
12
  // limitations under the License.
17
- const material_1 = require("@mui/material");
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "SeriesMarker", {
18
+ enumerable: true,
19
+ get: ()=>SeriesMarker
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
18
23
  function SeriesMarker(props) {
19
- const { markerColor } = props;
20
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
24
+ const { markerColor } = props;
25
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
26
+ sx: {
21
27
  display: 'inline-block',
22
28
  width: '12px',
23
29
  borderRadius: '2px',
24
30
  height: '12px',
25
31
  marginTop: 0.25,
26
32
  marginRight: 1,
27
- verticalAlign: 'top',
28
- }, style: { backgroundColor: markerColor } }));
33
+ verticalAlign: 'top'
34
+ },
35
+ style: {
36
+ backgroundColor: markerColor
37
+ }
38
+ });
29
39
  }
30
- exports.SeriesMarker = SeriesMarker;
@@ -1,30 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Tooltip = void 0;
27
- const jsx_runtime_1 = require("react/jsx-runtime");
28
1
  // Copyright 2022 The Perses Authors
29
2
  // Licensed under the Apache License, Version 2.0 (the "License");
30
3
  // you may not use this file except in compliance with the License.
@@ -37,52 +10,107 @@ const jsx_runtime_1 = require("react/jsx-runtime");
37
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
38
11
  // See the License for the specific language governing permissions and
39
12
  // limitations under the License.
40
- const react_1 = __importStar(require("react"));
41
- const material_1 = require("@mui/material");
42
- const focused_series_1 = require("./focused-series");
43
- const tooltip_model_1 = require("./tooltip-model");
44
- const TooltipContent_1 = require("./TooltipContent");
45
- const utils_1 = require("./utils");
46
- const Tooltip = react_1.default.memo(function Tooltip({ chartRef, chartData, wrapLabels, pinTooltip }) {
47
- var _a, _b;
48
- const [pinnedPos, setPinnedPos] = (0, react_1.useState)(null);
49
- const mousePos = (0, tooltip_model_1.useMousePosition)();
50
- if (mousePos === null || mousePos.target === null)
51
- return null;
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "Tooltip", {
18
+ enumerable: true,
19
+ get: ()=>Tooltip
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
23
+ const _material = require("@mui/material");
24
+ const _focusedSeries = require("./focused-series");
25
+ const _tooltipModel = require("./tooltip-model");
26
+ const _tooltipContent = require("./TooltipContent");
27
+ const _utils = require("./utils");
28
+ function _getRequireWildcardCache(nodeInterop) {
29
+ if (typeof WeakMap !== "function") return null;
30
+ var cacheBabelInterop = new WeakMap();
31
+ var cacheNodeInterop = new WeakMap();
32
+ return (_getRequireWildcardCache = function(nodeInterop) {
33
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
34
+ })(nodeInterop);
35
+ }
36
+ function _interopRequireWildcard(obj, nodeInterop) {
37
+ if (!nodeInterop && obj && obj.__esModule) {
38
+ return obj;
39
+ }
40
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
41
+ return {
42
+ default: obj
43
+ };
44
+ }
45
+ var cache = _getRequireWildcardCache(nodeInterop);
46
+ if (cache && cache.has(obj)) {
47
+ return cache.get(obj);
48
+ }
49
+ var newObj = {};
50
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
51
+ for(var key in obj){
52
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
53
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
54
+ if (desc && (desc.get || desc.set)) {
55
+ Object.defineProperty(newObj, key, desc);
56
+ } else {
57
+ newObj[key] = obj[key];
58
+ }
59
+ }
60
+ }
61
+ newObj.default = obj;
62
+ if (cache) {
63
+ cache.set(obj, newObj);
64
+ }
65
+ return newObj;
66
+ }
67
+ const Tooltip = /*#__PURE__*/ _react.default.memo(function Tooltip({ chartRef , chartData , wrapLabels , pinTooltip }) {
68
+ const [pinnedPos, setPinnedPos] = (0, _react.useState)(null);
69
+ const mousePos = (0, _tooltipModel.useMousePosition)();
70
+ if (mousePos === null || mousePos.target === null) return null;
52
71
  // ensure user is hovering over a chart before checking for nearby series
53
- if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS')
54
- return null;
72
+ if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
55
73
  const chart = chartRef.current;
56
- const focusedSeries = (0, focused_series_1.getFocusedSeriesData)(mousePos, chartData, pinnedPos, chart);
57
- const chartWidth = (_a = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && _a !== void 0 ? _a : 750;
58
- const chartHeight = (_b = chart === null || chart === void 0 ? void 0 : chart.getHeight()) !== null && _b !== void 0 ? _b : 230;
59
- const cursorTransform = (0, utils_1.assembleTransform)(mousePos, focusedSeries.length, chartWidth, chartHeight, pinnedPos);
74
+ const focusedSeries = (0, _focusedSeries.getFocusedSeriesData)(mousePos, chartData, pinnedPos, chart);
75
+ var ref;
76
+ const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : 750;
77
+ var ref1;
78
+ const chartHeight = (ref1 = chart === null || chart === void 0 ? void 0 : chart.getHeight()) !== null && ref1 !== void 0 ? ref1 : 230;
79
+ const cursorTransform = (0, _utils.assembleTransform)(mousePos, focusedSeries.length, chartWidth, chartHeight, pinnedPos);
60
80
  if (focusedSeries.length === 0) {
61
81
  return null;
62
82
  }
63
83
  if (pinTooltip === true && pinnedPos === null) {
64
84
  setPinnedPos(mousePos);
65
85
  }
66
- return ((0, jsx_runtime_1.jsx)(material_1.Portal, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: (theme) => ({
67
- maxWidth: tooltip_model_1.TOOLTIP_MAX_WIDTH,
68
- maxHeight: tooltip_model_1.TOOLTIP_MAX_HEIGHT,
69
- position: 'absolute',
70
- top: 0,
71
- left: 0,
72
- backgroundColor: '#2E313E',
73
- borderRadius: '6px',
74
- color: '#fff',
75
- fontSize: '11px',
76
- visibility: 'visible',
77
- opacity: 1,
78
- transition: 'all 0.1s ease-out',
79
- zIndex: theme.zIndex.tooltip,
80
- overflow: 'hidden',
81
- '&:hover': {
82
- overflowY: 'auto',
83
- },
84
- }), style: {
85
- transform: cursorTransform,
86
- }, children: (0, jsx_runtime_1.jsx)(TooltipContent_1.TooltipContent, { focusedSeries: focusedSeries, wrapLabels: wrapLabels }) }) }));
86
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Portal, {
87
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
88
+ sx: (theme)=>({
89
+ maxWidth: _tooltipModel.TOOLTIP_MAX_WIDTH,
90
+ maxHeight: _tooltipModel.TOOLTIP_MAX_HEIGHT,
91
+ position: 'absolute',
92
+ top: 0,
93
+ left: 0,
94
+ backgroundColor: '#2E313E',
95
+ borderRadius: '6px',
96
+ color: '#fff',
97
+ fontSize: '11px',
98
+ visibility: 'visible',
99
+ opacity: 1,
100
+ transition: 'all 0.1s ease-out',
101
+ zIndex: theme.zIndex.tooltip,
102
+ overflow: 'hidden',
103
+ '&:hover': {
104
+ overflowY: 'auto'
105
+ }
106
+ }),
107
+ style: {
108
+ transform: cursorTransform
109
+ },
110
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_tooltipContent.TooltipContent, {
111
+ focusedSeries: focusedSeries,
112
+ wrapLabels: wrapLabels
113
+ })
114
+ })
115
+ });
87
116
  });
88
- exports.Tooltip = Tooltip;
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TooltipContent = void 0;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- // Copyright 2021 The Perses Authors
1
+ // Copyright 2022 The Perses Authors
6
2
  // Licensed under the Apache License, Version 2.0 (the "License");
7
3
  // you may not use this file except in compliance with the License.
8
4
  // You may obtain a copy of the License at
@@ -14,37 +10,86 @@ const jsx_runtime_1 = require("react/jsx-runtime");
14
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
11
  // See the License for the specific language governing permissions and
16
12
  // limitations under the License.
17
- const react_1 = require("react");
18
- const material_1 = require("@mui/material");
19
- const SeriesInfo_1 = require("./SeriesInfo");
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "TooltipContent", {
18
+ enumerable: true,
19
+ get: ()=>TooltipContent
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
23
+ const _material = require("@mui/material");
24
+ const _seriesInfo = require("./SeriesInfo");
20
25
  function TooltipContent(props) {
21
- const { focusedSeries, wrapLabels } = props;
26
+ const { focusedSeries , wrapLabels } = props;
22
27
  const seriesTime = focusedSeries && focusedSeries[0] && focusedSeries[0].date ? focusedSeries[0].date : null;
23
- const formatTimeSeriesHeader = (timeString) => {
28
+ const formatTimeSeriesHeader = (timeString)=>{
24
29
  const [month, year, time] = timeString.split(',');
25
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, { variant: "caption", sx: (theme) => ({
26
- color: theme.palette.common.white,
27
- }), children: [month, ", ", year, " \u2013"] }), (0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: (0, jsx_runtime_1.jsx)("strong", { children: time }) })] }));
30
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
31
+ children: [
32
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Typography, {
33
+ variant: "caption",
34
+ sx: (theme)=>({
35
+ color: theme.palette.common.white
36
+ }),
37
+ children: [
38
+ month,
39
+ ", ",
40
+ year,
41
+ " –"
42
+ ]
43
+ }),
44
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
45
+ variant: "caption",
46
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)("strong", {
47
+ children: time
48
+ })
49
+ })
50
+ ]
51
+ });
28
52
  };
29
- const sortedFocusedSeries = (0, react_1.useMemo)(() => {
30
- if (focusedSeries === null)
31
- return null;
32
- return focusedSeries.sort((a, b) => (a.y > b.y ? -1 : 1));
33
- }, [focusedSeries]);
53
+ const sortedFocusedSeries = (0, _react.useMemo)(()=>{
54
+ if (focusedSeries === null) return null;
55
+ return focusedSeries.sort((a, b)=>a.y > b.y ? -1 : 1);
56
+ }, [
57
+ focusedSeries
58
+ ]);
34
59
  if (sortedFocusedSeries !== null && seriesTime !== null) {
35
- return ((0, jsx_runtime_1.jsxs)(material_1.Stack, { py: 1, px: 1.5, spacing: 0.5, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "caption", children: formatTimeSeriesHeader(seriesTime) }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: (theme) => ({
36
- borderColor: theme.palette.grey['500'],
37
- }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
38
- display: 'table',
39
- }, children: sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, markerColor }) => {
40
- if (datumIdx === null || seriesIdx === null)
41
- return null;
60
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
61
+ py: 1,
62
+ px: 1.5,
63
+ spacing: 0.5,
64
+ children: [
65
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
66
+ variant: "caption",
67
+ children: formatTimeSeriesHeader(seriesTime)
68
+ }),
69
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
70
+ sx: (theme)=>({
71
+ borderColor: theme.palette.grey['500']
72
+ })
73
+ }),
74
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
75
+ sx: {
76
+ display: 'table'
77
+ },
78
+ children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , markerColor })=>{
79
+ if (datumIdx === null || seriesIdx === null) return null;
42
80
  const key = seriesIdx.toString() + datumIdx.toString();
43
- return ((0, jsx_runtime_1.jsx)(SeriesInfo_1.SeriesInfo, { seriesName: seriesName, y: y, markerColor: markerColor, totalSeries: sortedFocusedSeries.length, wrapLabels: wrapLabels }, key));
44
- }) })] }));
45
- }
46
- else {
47
- return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
81
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesInfo.SeriesInfo, {
82
+ seriesName: seriesName,
83
+ y: y,
84
+ markerColor: markerColor,
85
+ totalSeries: sortedFocusedSeries.length,
86
+ wrapLabels: wrapLabels
87
+ }, key);
88
+ })
89
+ })
90
+ ]
91
+ });
92
+ } else {
93
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {});
48
94
  }
49
95
  }
50
- exports.TooltipContent = TooltipContent;