@perses-dev/components 0.14.0 → 0.16.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 (178) hide show
  1. package/dist/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.d.ts +0 -0
  2. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -0
  3. package/dist/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.js +38 -33
  4. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -0
  5. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts +11 -0
  6. package/dist/DateTimeRangePicker/DateTimeRangePicker.d.ts.map +1 -0
  7. package/dist/DateTimeRangePicker/DateTimeRangePicker.js +77 -0
  8. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -0
  9. package/dist/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.d.ts +0 -0
  10. package/dist/DateTimeRangePicker/TimeRangeSelector.d.ts.map +1 -0
  11. package/dist/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.js +0 -0
  12. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -0
  13. package/dist/{TimeRangeSelector → DateTimeRangePicker}/index.d.ts +1 -0
  14. package/dist/DateTimeRangePicker/index.d.ts.map +1 -0
  15. package/dist/{TimeRangeSelector → DateTimeRangePicker}/index.js +1 -0
  16. package/dist/DateTimeRangePicker/index.js.map +1 -0
  17. package/dist/{TimeRangeSelector → DateTimeRangePicker}/utils.d.ts +0 -0
  18. package/dist/DateTimeRangePicker/utils.d.ts.map +1 -0
  19. package/dist/{TimeRangeSelector → DateTimeRangePicker}/utils.js +0 -0
  20. package/dist/DateTimeRangePicker/utils.js.map +1 -0
  21. package/dist/Legend/CompactLegend.d.ts +6 -1
  22. package/dist/Legend/CompactLegend.d.ts.map +1 -1
  23. package/dist/Legend/CompactLegend.js +16 -7
  24. package/dist/Legend/CompactLegend.js.map +1 -1
  25. package/dist/Legend/Legend.d.ts.map +1 -1
  26. package/dist/Legend/Legend.js +4 -9
  27. package/dist/Legend/Legend.js.map +1 -1
  28. package/dist/Legend/ListLegend.d.ts +3 -0
  29. package/dist/Legend/ListLegend.d.ts.map +1 -1
  30. package/dist/Legend/ListLegend.js +18 -2
  31. package/dist/Legend/ListLegend.js.map +1 -1
  32. package/dist/Legend/ListLegendItem.d.ts +2 -1
  33. package/dist/Legend/ListLegendItem.d.ts.map +1 -1
  34. package/dist/Legend/ListLegendItem.js +11 -9
  35. package/dist/Legend/ListLegendItem.js.map +1 -1
  36. package/dist/LineChart/LineChart.js +2 -1
  37. package/dist/LineChart/LineChart.js.map +1 -1
  38. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts +13 -0
  39. package/dist/OptionsEditorLayout/OptionsEditorColumn.d.ts.map +1 -0
  40. package/dist/OptionsEditorLayout/OptionsEditorColumn.js +28 -0
  41. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -0
  42. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts +5 -0
  43. package/dist/OptionsEditorLayout/OptionsEditorControl.d.ts.map +1 -0
  44. package/dist/OptionsEditorLayout/OptionsEditorControl.js +50 -0
  45. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -0
  46. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts +13 -0
  47. package/dist/OptionsEditorLayout/OptionsEditorGrid.d.ts.map +1 -0
  48. package/dist/OptionsEditorLayout/OptionsEditorGrid.js +26 -0
  49. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -0
  50. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts +13 -0
  51. package/dist/OptionsEditorLayout/OptionsEditorGroup.d.ts.map +1 -0
  52. package/dist/OptionsEditorLayout/OptionsEditorGroup.js +36 -0
  53. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -0
  54. package/dist/OptionsEditorLayout/index.d.ts +5 -0
  55. package/dist/OptionsEditorLayout/index.d.ts.map +1 -0
  56. package/dist/OptionsEditorLayout/index.js +18 -0
  57. package/dist/OptionsEditorLayout/index.js.map +1 -0
  58. package/dist/Tooltip/SeriesInfo.d.ts +1 -0
  59. package/dist/Tooltip/SeriesInfo.d.ts.map +1 -1
  60. package/dist/Tooltip/SeriesInfo.js +3 -3
  61. package/dist/Tooltip/SeriesInfo.js.map +1 -1
  62. package/dist/Tooltip/Tooltip.d.ts +2 -1
  63. package/dist/Tooltip/Tooltip.d.ts.map +1 -1
  64. package/dist/Tooltip/Tooltip.js +2 -2
  65. package/dist/Tooltip/Tooltip.js.map +1 -1
  66. package/dist/Tooltip/TooltipContent.d.ts.map +1 -1
  67. package/dist/Tooltip/TooltipContent.js +2 -1
  68. package/dist/Tooltip/TooltipContent.js.map +1 -1
  69. package/dist/Tooltip/focused-series.d.ts +4 -3
  70. package/dist/Tooltip/focused-series.d.ts.map +1 -1
  71. package/dist/Tooltip/focused-series.js +6 -3
  72. package/dist/Tooltip/focused-series.js.map +1 -1
  73. package/dist/Tooltip/focused-series.test.js +20 -2
  74. package/dist/Tooltip/focused-series.test.js.map +1 -1
  75. package/dist/UnitSelector/UnitSelector.d.ts +8 -0
  76. package/dist/UnitSelector/UnitSelector.d.ts.map +1 -0
  77. package/dist/UnitSelector/UnitSelector.js +112 -0
  78. package/dist/UnitSelector/UnitSelector.js.map +1 -0
  79. package/dist/UnitSelector/UnitSelector.test.d.ts +2 -0
  80. package/dist/UnitSelector/UnitSelector.test.d.ts.map +1 -0
  81. package/dist/UnitSelector/UnitSelector.test.js +211 -0
  82. package/dist/UnitSelector/UnitSelector.test.js.map +1 -0
  83. package/dist/UnitSelector/index.d.ts +2 -0
  84. package/dist/UnitSelector/index.d.ts.map +1 -0
  85. package/dist/UnitSelector/index.js +15 -0
  86. package/dist/UnitSelector/index.js.map +1 -0
  87. package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/AbsoluteTimePicker.js +37 -32
  88. package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +83 -0
  89. package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/TimeRangeSelector.js +0 -0
  90. package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/index.js +1 -0
  91. package/dist/cjs/{TimeRangeSelector → DateTimeRangePicker}/utils.js +0 -0
  92. package/dist/cjs/Legend/CompactLegend.js +12 -6
  93. package/dist/cjs/Legend/Legend.js +4 -9
  94. package/dist/cjs/Legend/ListLegend.js +15 -1
  95. package/dist/cjs/Legend/ListLegendItem.js +48 -13
  96. package/dist/cjs/LineChart/LineChart.js +2 -1
  97. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +32 -0
  98. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +61 -0
  99. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +29 -0
  100. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +40 -0
  101. package/dist/cjs/OptionsEditorLayout/index.js +31 -0
  102. package/dist/cjs/Tooltip/SeriesInfo.js +3 -3
  103. package/dist/cjs/Tooltip/Tooltip.js +2 -2
  104. package/dist/cjs/Tooltip/TooltipContent.js +2 -1
  105. package/dist/cjs/Tooltip/focused-series.js +6 -3
  106. package/dist/cjs/Tooltip/focused-series.test.js +20 -2
  107. package/dist/cjs/UnitSelector/UnitSelector.js +118 -0
  108. package/dist/cjs/UnitSelector/UnitSelector.test.js +218 -0
  109. package/dist/cjs/UnitSelector/index.js +28 -0
  110. package/dist/cjs/index.js +4 -2
  111. package/dist/cjs/model/units/bytes.js +60 -0
  112. package/dist/cjs/model/units/constants.js +23 -0
  113. package/dist/cjs/model/units/decimal.js +67 -0
  114. package/dist/cjs/model/units/index.js +30 -0
  115. package/dist/cjs/model/units/percent.js +64 -0
  116. package/dist/cjs/model/units/time.js +138 -0
  117. package/dist/cjs/model/units/types.js +28 -0
  118. package/dist/cjs/model/units/units.js +104 -0
  119. package/dist/cjs/utils/component-ids.js +31 -0
  120. package/dist/cjs/utils/index.js +1 -0
  121. package/dist/index.d.ts +4 -2
  122. package/dist/index.d.ts.map +1 -1
  123. package/dist/index.js +4 -2
  124. package/dist/index.js.map +1 -1
  125. package/dist/model/units/bytes.d.ts +12 -0
  126. package/dist/model/units/bytes.d.ts.map +1 -0
  127. package/dist/model/units/bytes.js +48 -0
  128. package/dist/model/units/bytes.js.map +1 -0
  129. package/dist/model/units/constants.d.ts +2 -0
  130. package/dist/model/units/constants.d.ts.map +1 -0
  131. package/dist/model/units/constants.js +17 -0
  132. package/dist/model/units/constants.js.map +1 -0
  133. package/dist/model/units/decimal.d.ts +24 -0
  134. package/dist/model/units/decimal.d.ts.map +1 -0
  135. package/dist/model/units/decimal.js +59 -0
  136. package/dist/model/units/decimal.js.map +1 -0
  137. package/dist/model/units/index.d.ts +4 -0
  138. package/dist/model/units/index.d.ts.map +1 -0
  139. package/dist/model/units/index.js +17 -0
  140. package/dist/model/units/index.js.map +1 -0
  141. package/dist/model/units/percent.d.ts +12 -0
  142. package/dist/model/units/percent.d.ts.map +1 -0
  143. package/dist/model/units/percent.js +51 -0
  144. package/dist/model/units/percent.js.map +1 -0
  145. package/dist/model/units/time.d.ts +11 -0
  146. package/dist/model/units/time.d.ts.map +1 -0
  147. package/dist/model/units/time.js +125 -0
  148. package/dist/model/units/time.js.map +1 -0
  149. package/dist/model/units/types.d.ts +38 -0
  150. package/dist/model/units/types.d.ts.map +1 -0
  151. package/dist/model/units/types.js +22 -0
  152. package/dist/model/units/types.js.map +1 -0
  153. package/dist/model/units/units.d.ts +40 -0
  154. package/dist/model/units/units.d.ts.map +1 -0
  155. package/dist/model/units/units.js +83 -0
  156. package/dist/model/units/units.js.map +1 -0
  157. package/dist/utils/component-ids.d.ts +8 -0
  158. package/dist/utils/component-ids.d.ts.map +1 -0
  159. package/dist/utils/component-ids.js +27 -0
  160. package/dist/utils/component-ids.js.map +1 -0
  161. package/dist/utils/index.d.ts +1 -0
  162. package/dist/utils/index.d.ts.map +1 -1
  163. package/dist/utils/index.js +1 -0
  164. package/dist/utils/index.js.map +1 -1
  165. package/package.json +2 -2
  166. package/dist/TimeRangeSelector/AbsoluteTimePicker.d.ts.map +0 -1
  167. package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +0 -1
  168. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts.map +0 -1
  169. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +0 -1
  170. package/dist/TimeRangeSelector/index.d.ts.map +0 -1
  171. package/dist/TimeRangeSelector/index.js.map +0 -1
  172. package/dist/TimeRangeSelector/utils.d.ts.map +0 -1
  173. package/dist/TimeRangeSelector/utils.js.map +0 -1
  174. package/dist/cjs/model/units.js +0 -203
  175. package/dist/model/units.d.ts +0 -36
  176. package/dist/model/units.d.ts.map +0 -1
  177. package/dist/model/units.js +0 -196
  178. package/dist/model/units.js.map +0 -1
@@ -61,10 +61,10 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
61
61
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.LocalizationProvider, {
62
62
  dateAdapter: _adapterDateFns.AdapterDateFns,
63
63
  children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
64
- spacing: 3,
65
- sx: {
66
- padding: (theme)=>theme.spacing(1, 2, 3)
67
- },
64
+ spacing: 2,
65
+ sx: (theme)=>({
66
+ padding: theme.spacing(1, 0, 2)
67
+ }),
68
68
  children: [
69
69
  showStartCalendar && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
70
70
  sx: (theme)=>({
@@ -80,7 +80,9 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
80
80
  }
81
81
  }),
82
82
  children: [
83
- /*#__PURE__*/ (0, _jsxRuntime.jsx)("h3", {
83
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
84
+ variant: "h3",
85
+ padding: 1,
84
86
  children: "Select Start Time"
85
87
  }),
86
88
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
@@ -119,7 +121,9 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
119
121
  }
120
122
  }),
121
123
  children: [
122
- /*#__PURE__*/ (0, _jsxRuntime.jsx)("h3", {
124
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
125
+ variant: "h3",
126
+ padding: 1,
123
127
  children: "Select End Time"
124
128
  }),
125
129
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
@@ -147,33 +151,34 @@ const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
147
151
  })
148
152
  ]
149
153
  }),
150
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
151
- fullWidth: true,
152
- onChange: (event)=>{
153
- // TODO: add helperText, fix validation after we decide on form state solution
154
- updateDateRange(event.target.value, true);
155
- },
156
- value: (0, _dateFns.format)(timeRange.start, DATE_TIME_FORMAT),
157
- label: "Start Time",
158
- placeholder: "mm/dd/yyyy hh:mm",
159
- // tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
160
- type: "tel"
161
- }),
162
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
163
- sx: (theme)=>({
164
- margin: theme.spacing(2, 0),
165
- borderColor: theme.palette.grey['500']
154
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
155
+ direction: "row",
156
+ alignItems: "center",
157
+ gap: 1,
158
+ pl: 1,
159
+ pr: 1,
160
+ children: [
161
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
162
+ onChange: (event)=>{
163
+ // TODO: add helperText, fix validation after we decide on form state solution
164
+ updateDateRange(event.target.value, true);
165
+ },
166
+ value: (0, _dateFns.format)(timeRange.start, DATE_TIME_FORMAT),
167
+ label: "Start Time",
168
+ placeholder: "mm/dd/yyyy hh:mm",
169
+ // tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
170
+ type: "tel"
171
+ }),
172
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
173
+ onChange: (event)=>{
174
+ updateDateRange(event.target.value, false);
175
+ },
176
+ value: (0, _dateFns.format)(timeRange.end, DATE_TIME_FORMAT),
177
+ label: "End Time",
178
+ placeholder: "mm/dd/yyyy hh:mm",
179
+ type: "tel"
166
180
  })
167
- }),
168
- /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
169
- fullWidth: true,
170
- onChange: (event)=>{
171
- updateDateRange(event.target.value, false);
172
- },
173
- value: (0, _dateFns.format)(timeRange.end, DATE_TIME_FORMAT),
174
- label: "End Time",
175
- placeholder: "mm/dd/yyyy hh:mm",
176
- type: "tel"
181
+ ]
177
182
  })
178
183
  ]
179
184
  })
@@ -0,0 +1,83 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "DateTimeRangePicker", {
18
+ enumerable: true,
19
+ get: ()=>DateTimeRangePicker
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _react = require("react");
23
+ const _material = require("@mui/material");
24
+ const _core = require("@perses-dev/core");
25
+ const _absoluteTimePicker = require("./AbsoluteTimePicker");
26
+ const _timeRangeSelector = require("./TimeRangeSelector");
27
+ function DateTimeRangePicker(props) {
28
+ const { value , onChange , timeOptions } = props;
29
+ const [showCustomDateSelector, setShowCustomDateSelector] = (0, _react.useState)(false);
30
+ const anchorEl = (0, _react.useRef)();
31
+ const convertedTimeRange = (0, _react.useMemo)(()=>{
32
+ return (0, _core.isRelativeTimeRange)(value) ? (0, _core.toAbsoluteTimeRange)(value) : value;
33
+ }, [
34
+ value
35
+ ]);
36
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
37
+ direction: "row",
38
+ spacing: 1,
39
+ children: [
40
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Popover, {
41
+ anchorEl: anchorEl.current,
42
+ anchorOrigin: {
43
+ vertical: 'bottom',
44
+ horizontal: 'center'
45
+ },
46
+ open: showCustomDateSelector,
47
+ onClose: ()=>setShowCustomDateSelector(false),
48
+ sx: (theme)=>({
49
+ padding: theme.spacing(2)
50
+ }),
51
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_absoluteTimePicker.AbsoluteTimePicker, {
52
+ initialTimeRange: convertedTimeRange,
53
+ onChange: (value)=>{
54
+ onChange(value);
55
+ setShowCustomDateSelector(false);
56
+ }
57
+ })
58
+ }),
59
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
60
+ fullWidth: true,
61
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
62
+ ref: anchorEl,
63
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_timeRangeSelector.TimeRangeSelector, {
64
+ timeOptions: timeOptions,
65
+ value: value,
66
+ onSelectChange: (event)=>{
67
+ const duration = event.target.value;
68
+ const relativeTimeInput = {
69
+ pastDuration: duration,
70
+ end: new Date()
71
+ };
72
+ onChange(relativeTimeInput);
73
+ setShowCustomDateSelector(false);
74
+ },
75
+ onCustomClick: ()=>{
76
+ setShowCustomDateSelector(true);
77
+ }
78
+ })
79
+ })
80
+ })
81
+ ]
82
+ });
83
+ }
@@ -14,6 +14,7 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ _exportStar(require("./DateTimeRangePicker"), exports);
17
18
  _exportStar(require("./TimeRangeSelector"), exports);
18
19
  _exportStar(require("./AbsoluteTimePicker"), exports);
19
20
  function _exportStar(from, to) {
@@ -21,15 +21,21 @@ Object.defineProperty(exports, "CompactLegend", {
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
23
23
  const _listLegendItem = require("./ListLegendItem");
24
- function CompactLegend({ items }) {
25
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
26
- direction: "row",
27
- spacing: 2,
24
+ function CompactLegend({ height , items }) {
25
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
28
26
  sx: {
29
- flexWrap: 'wrap'
27
+ width: '100%',
28
+ height,
29
+ paddingTop: 1,
30
+ overflowY: 'scroll'
30
31
  },
31
32
  children: items.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
32
- item: item
33
+ item: item,
34
+ sx: {
35
+ width: 'auto',
36
+ float: 'left',
37
+ paddingRight: 1.5
38
+ }
33
39
  }, item.id))
34
40
  });
35
41
  }
@@ -27,7 +27,7 @@ function Legend({ width , height , options , data }) {
27
27
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
28
28
  sx: {
29
29
  width: width,
30
- height: height,
30
+ height: '100%',
31
31
  position: 'absolute',
32
32
  top: 0,
33
33
  right: 0,
@@ -38,13 +38,8 @@ function Legend({ width , height , options , data }) {
38
38
  })
39
39
  });
40
40
  }
41
- return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
42
- sx: {
43
- height: 50,
44
- overflowY: 'scroll'
45
- },
46
- children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_compactLegend.CompactLegend, {
47
- items: data
48
- })
41
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_compactLegend.CompactLegend, {
42
+ items: data,
43
+ height: height
49
44
  });
50
45
  }
@@ -22,9 +22,23 @@ const _jsxRuntime = require("react/jsx-runtime");
22
22
  const _material = require("@mui/material");
23
23
  const _listLegendItem = require("./ListLegendItem");
24
24
  function ListLegend({ items }) {
25
+ // show full labels on hover when there are many total series
26
+ const truncateLabels = items.length > 5;
25
27
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.List, {
26
28
  children: items.map((item)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_listLegendItem.ListLegendItem, {
27
- item: item
29
+ item: item,
30
+ sx: {
31
+ width: 190,
32
+ textOverflow: 'ellipsis',
33
+ wordBreak: 'break-word',
34
+ overflow: truncateLabels ? 'hidden' : 'visible',
35
+ whiteSpace: truncateLabels ? 'nowrap' : 'normal',
36
+ // TODO: add optional hover effect to show unformatted label
37
+ '&:hover': {
38
+ overflow: 'visible',
39
+ whiteSpace: 'normal'
40
+ }
41
+ }
28
42
  }, item.id))
29
43
  });
30
44
  }
@@ -19,24 +19,59 @@ Object.defineProperty(exports, "ListLegendItem", {
19
19
  get: ()=>ListLegendItem
20
20
  });
21
21
  const _jsxRuntime = require("react/jsx-runtime");
22
- const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
22
+ const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
23
23
  const _material = require("@mui/material");
24
+ const _utils = require("../utils");
24
25
  const _legendColorBadge = require("./LegendColorBadge");
25
- function _interopRequireDefault(obj) {
26
- return obj && obj.__esModule ? obj : {
27
- default: obj
28
- };
26
+ function _getRequireWildcardCache(nodeInterop) {
27
+ if (typeof WeakMap !== "function") return null;
28
+ var cacheBabelInterop = new WeakMap();
29
+ var cacheNodeInterop = new WeakMap();
30
+ return (_getRequireWildcardCache = function(nodeInterop) {
31
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
32
+ })(nodeInterop);
29
33
  }
30
- const ListLegendItem = /*#__PURE__*/ _react.default.memo(function ListLegendItem({ item }) {
31
- return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.ListItem, {
32
- dense: true,
33
- sx: {
34
- display: 'flex',
35
- maxWidth: 270,
34
+ function _interopRequireWildcard(obj, nodeInterop) {
35
+ if (!nodeInterop && obj && obj.__esModule) {
36
+ return obj;
37
+ }
38
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
39
+ return {
40
+ default: obj
41
+ };
42
+ }
43
+ var cache = _getRequireWildcardCache(nodeInterop);
44
+ if (cache && cache.has(obj)) {
45
+ return cache.get(obj);
46
+ }
47
+ var newObj = {};
48
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
49
+ for(var key in obj){
50
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
51
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
52
+ if (desc && (desc.get || desc.set)) {
53
+ Object.defineProperty(newObj, key, desc);
54
+ } else {
55
+ newObj[key] = obj[key];
56
+ }
57
+ }
58
+ }
59
+ newObj.default = obj;
60
+ if (cache) {
61
+ cache.set(obj, newObj);
62
+ }
63
+ return newObj;
64
+ }
65
+ const ListLegendItem = /*#__PURE__*/ _react.default.memo(function ListLegendItem({ item , sx , ...others }) {
66
+ return /*#__PURE__*/ (0, _react.createElement)(_material.ListItem, {
67
+ ...others,
68
+ sx: (0, _utils.combineSx)({
36
69
  padding: 0,
37
70
  cursor: 'pointer'
38
- },
71
+ }, sx),
72
+ dense: true,
39
73
  "data-testid": `legend-item-${item.color}`,
74
+ key: item.id,
40
75
  onClick: item.onClick,
41
76
  selected: item.isSelected,
42
77
  children: [
@@ -53,5 +88,5 @@ const ListLegendItem = /*#__PURE__*/ _react.default.memo(function ListLegendItem
53
88
  primary: item.label
54
89
  })
55
90
  ]
56
- }, item.id);
91
+ });
57
92
  });
@@ -187,7 +187,8 @@ function LineChart({ height , data , unit , grid , legend , visualMap , onDataZo
187
187
  chartRef: chartRef,
188
188
  chartData: data,
189
189
  wrapLabels: true,
190
- pinTooltip: pinTooltip
190
+ pinTooltip: pinTooltip,
191
+ unit: unit
191
192
  }),
192
193
  /*#__PURE__*/ (0, _jsxRuntime.jsx)(_echart.EChart, {
193
194
  sx: {
@@ -0,0 +1,32 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "OptionsEditorColumn", {
18
+ enumerable: true,
19
+ get: ()=>OptionsEditorColumn
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const OptionsEditorColumn = ({ children })=>{
24
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
25
+ item: true,
26
+ xs: 4,
27
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
28
+ spacing: 3,
29
+ children: children
30
+ })
31
+ });
32
+ };
@@ -0,0 +1,61 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "OptionsEditorControl", {
18
+ enumerable: true,
19
+ get: ()=>OptionsEditorControl
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
24
+ const _utils = require("../utils");
25
+ function _interopRequireDefault(obj) {
26
+ return obj && obj.__esModule ? obj : {
27
+ default: obj
28
+ };
29
+ }
30
+ const OptionsEditorControl = ({ label , control })=>{
31
+ // Make sure we have a unique ID we can use for associating labels and
32
+ // controls for a11y.
33
+ const generatedControlId = (0, _utils.useId)('EditorSectionControl');
34
+ const controlId = `${generatedControlId}-control`;
35
+ const controlProps = {
36
+ id: controlId
37
+ };
38
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormControl, {
39
+ children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
40
+ direction: "row",
41
+ alignItems: "center",
42
+ justifyContent: "space-between",
43
+ children: [
44
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.FormLabel, {
45
+ htmlFor: controlId,
46
+ children: label
47
+ }),
48
+ /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
49
+ sx: {
50
+ width: '160px',
51
+ textAlign: 'right'
52
+ },
53
+ children: [
54
+ " ",
55
+ /*#__PURE__*/ _react.default.cloneElement(control, controlProps)
56
+ ]
57
+ })
58
+ ]
59
+ })
60
+ });
61
+ };
@@ -0,0 +1,29 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "OptionsEditorGrid", {
18
+ enumerable: true,
19
+ get: ()=>OptionsEditorGrid
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const OptionsEditorGrid = ({ children })=>{
24
+ return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Grid, {
25
+ container: true,
26
+ spacing: 8,
27
+ children: children
28
+ });
29
+ };
@@ -0,0 +1,40 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "OptionsEditorGroup", {
18
+ enumerable: true,
19
+ get: ()=>OptionsEditorGroup
20
+ });
21
+ const _jsxRuntime = require("react/jsx-runtime");
22
+ const _material = require("@mui/material");
23
+ const OptionsEditorGroup = ({ title , children })=>{
24
+ return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
25
+ children: [
26
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Typography, {
27
+ variant: "overline",
28
+ component: "h4",
29
+ borderBottom: 1,
30
+ borderColor: "grey.300",
31
+ marginBottom: (theme)=>theme.spacing(1),
32
+ children: title
33
+ }),
34
+ /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Stack, {
35
+ spacing: 1,
36
+ children: children
37
+ })
38
+ ]
39
+ });
40
+ };
@@ -0,0 +1,31 @@
1
+ // Copyright 2022 The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ _exportStar(require("./OptionsEditorColumn"), exports);
18
+ _exportStar(require("./OptionsEditorControl"), exports);
19
+ _exportStar(require("./OptionsEditorGrid"), exports);
20
+ _exportStar(require("./OptionsEditorGroup"), exports);
21
+ function _exportStar(from, to) {
22
+ Object.keys(from).forEach(function(k) {
23
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
24
+ enumerable: true,
25
+ get: function() {
26
+ return from[k];
27
+ }
28
+ });
29
+ });
30
+ return from;
31
+ }
@@ -23,7 +23,7 @@ const _material = require("@mui/material");
23
23
  const _seriesMarker = require("./SeriesMarker");
24
24
  const _tooltipModel = require("./tooltip-model");
25
25
  function SeriesInfo(props) {
26
- const { seriesName , y , markerColor , totalSeries , wrapLabels } = props;
26
+ const { seriesName , formattedY , markerColor , totalSeries , wrapLabels } = props;
27
27
  // TODO (sjcobb): regex to remove __name__, improve series labels
28
28
  const formattedSeriesLabels = seriesName.replace(/[{}"]/g, '');
29
29
  if (totalSeries === 1) {
@@ -56,7 +56,7 @@ function SeriesInfo(props) {
56
56
  fontWeight: 700,
57
57
  paddingLeft: '2px'
58
58
  }),
59
- children: y
59
+ children: formattedY
60
60
  })
61
61
  ]
62
62
  })
@@ -142,7 +142,7 @@ function SeriesInfo(props) {
142
142
  textAlign: 'right',
143
143
  verticalAlign: 'top'
144
144
  },
145
- children: y
145
+ children: formattedY
146
146
  })
147
147
  ]
148
148
  });
@@ -64,14 +64,14 @@ function _interopRequireWildcard(obj, nodeInterop) {
64
64
  }
65
65
  return newObj;
66
66
  }
67
- const Tooltip = /*#__PURE__*/ _react.default.memo(function Tooltip({ chartRef , chartData , wrapLabels , pinTooltip }) {
67
+ const Tooltip = /*#__PURE__*/ _react.default.memo(function Tooltip({ chartRef , chartData , wrapLabels , pinTooltip , unit }) {
68
68
  const [pinnedPos, setPinnedPos] = (0, _react.useState)(null);
69
69
  const mousePos = (0, _tooltipModel.useMousePosition)();
70
70
  if (mousePos === null || mousePos.target === null) return null;
71
71
  // ensure user is hovering over a chart before checking for nearby series
72
72
  if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
73
73
  const chart = chartRef.current;
74
- const focusedSeries = (0, _focusedSeries.getFocusedSeriesData)(mousePos, chartData, pinnedPos, chart);
74
+ const focusedSeries = (0, _focusedSeries.getFocusedSeriesData)(mousePos, chartData, pinnedPos, chart, unit);
75
75
  var ref;
76
76
  const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : 750;
77
77
  var ref1;
@@ -75,12 +75,13 @@ function TooltipContent(props) {
75
75
  sx: {
76
76
  display: 'table'
77
77
  },
78
- children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , markerColor })=>{
78
+ children: sortedFocusedSeries.map(({ datumIdx , seriesIdx , seriesName , y , formattedY , markerColor })=>{
79
79
  if (datumIdx === null || seriesIdx === null) return null;
80
80
  const key = seriesIdx.toString() + datumIdx.toString();
81
81
  return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_seriesInfo.SeriesInfo, {
82
82
  seriesName: seriesName,
83
83
  y: y,
84
+ formattedY: formattedY,
84
85
  markerColor: markerColor,
85
86
  totalSeries: sortedFocusedSeries.length,
86
87
  wrapLabels: wrapLabels