@perses-dev/components 0.50.0 → 0.51.0-beta.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 (153) hide show
  1. package/dist/ColorPicker/ColorPicker.js +2 -2
  2. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  3. package/dist/ContentWithLegend/model/content-with-legend-model.js +2 -3
  4. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  5. package/dist/DragAndDrop/DragButton.d.ts +2 -2
  6. package/dist/DragAndDrop/DragButton.d.ts.map +1 -1
  7. package/dist/DragAndDrop/DragButton.js +6 -4
  8. package/dist/DragAndDrop/DragButton.js.map +1 -1
  9. package/dist/Drawer/Drawer.js +1 -1
  10. package/dist/Drawer/Drawer.js.map +1 -1
  11. package/dist/EChart/EChart.js +3 -4
  12. package/dist/EChart/EChart.js.map +1 -1
  13. package/dist/GaugeChart/GaugeChart.js +2 -5
  14. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  15. package/dist/InfoTooltip/InfoTooltip.js +5 -4
  16. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  17. package/dist/Legend/ListLegendItem.js +3 -4
  18. package/dist/Legend/ListLegendItem.js.map +1 -1
  19. package/dist/LineChart/LineChart.js +4 -8
  20. package/dist/LineChart/LineChart.js.map +1 -1
  21. package/dist/LinksEditor/LinksEditor.js +9 -18
  22. package/dist/LinksEditor/LinksEditor.js.map +1 -1
  23. package/dist/Overlay/Overlay.js +1 -1
  24. package/dist/Overlay/Overlay.js.map +1 -1
  25. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +1 -2
  26. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  27. package/dist/StatChart/StatChart.d.ts +4 -4
  28. package/dist/StatChart/StatChart.d.ts.map +1 -1
  29. package/dist/StatChart/StatChart.js +9 -15
  30. package/dist/StatChart/StatChart.js.map +1 -1
  31. package/dist/StatChart/calculateFontSize.js +2 -4
  32. package/dist/StatChart/calculateFontSize.js.map +1 -1
  33. package/dist/StatChart/utils/formatStatChartValue.d.ts +3 -0
  34. package/dist/StatChart/utils/formatStatChartValue.d.ts.map +1 -0
  35. package/dist/StatChart/utils/formatStatChartValue.js +26 -0
  36. package/dist/StatChart/utils/formatStatChartValue.js.map +1 -0
  37. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts +16 -3
  38. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts.map +1 -1
  39. package/dist/StatusHistoryChart/StatusHistoryChart.js +9 -26
  40. package/dist/StatusHistoryChart/StatusHistoryChart.js.map +1 -1
  41. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts +2 -1
  42. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts.map +1 -1
  43. package/dist/StatusHistoryChart/StatusHistoryTooltip.js +3 -3
  44. package/dist/StatusHistoryChart/StatusHistoryTooltip.js.map +1 -1
  45. package/dist/StatusHistoryChart/utils/get-color.d.ts +1 -1
  46. package/dist/StatusHistoryChart/utils/get-color.d.ts.map +1 -1
  47. package/dist/StatusHistoryChart/utils/get-color.js +5 -5
  48. package/dist/StatusHistoryChart/utils/get-color.js.map +1 -1
  49. package/dist/Table/Table.js +5 -5
  50. package/dist/Table/Table.js.map +1 -1
  51. package/dist/Table/TableCell.js +5 -6
  52. package/dist/Table/TableCell.js.map +1 -1
  53. package/dist/Table/VirtualizedTable.js +11 -14
  54. package/dist/Table/VirtualizedTable.js.map +1 -1
  55. package/dist/Table/hooks/useTableKeyboardNav.js +1 -1
  56. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
  57. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +7 -13
  58. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
  59. package/dist/Table/model/table-model.js +1 -1
  60. package/dist/Table/model/table-model.js.map +1 -1
  61. package/dist/ThresholdsEditor/ThresholdsEditor.js +15 -23
  62. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  63. package/dist/TimeChart/TimeChart.js +3 -6
  64. package/dist/TimeChart/TimeChart.js.map +1 -1
  65. package/dist/TimeSeriesTooltip/LineChartTooltip.js +6 -11
  66. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  67. package/dist/TimeSeriesTooltip/SeriesInfo.js +1 -2
  68. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  69. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +2 -3
  70. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  71. package/dist/TimeSeriesTooltip/TooltipHeader.js +4 -10
  72. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  73. package/dist/TimeSeriesTooltip/nearby-series.js +13 -23
  74. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  75. package/dist/TimeSeriesTooltip/utils.js +2 -4
  76. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  77. package/dist/TransformsEditor/TransformEditor.js +4 -7
  78. package/dist/TransformsEditor/TransformEditor.js.map +1 -1
  79. package/dist/TransformsEditor/TransformEditorContainer.js +3 -5
  80. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  81. package/dist/TransformsEditor/TransformsEditor.js +3 -6
  82. package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
  83. package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +10 -0
  84. package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -0
  85. package/dist/ValueMappingEditor/ValueMappingEditor.js +374 -0
  86. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -0
  87. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +8 -0
  88. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -0
  89. package/dist/ValueMappingEditor/ValueMappingsEditor.js +118 -0
  90. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -0
  91. package/dist/ValueMappingEditor/index.d.ts +2 -0
  92. package/dist/ValueMappingEditor/index.d.ts.map +1 -0
  93. package/dist/ValueMappingEditor/index.js +15 -0
  94. package/dist/ValueMappingEditor/index.js.map +1 -0
  95. package/dist/cjs/ColorPicker/ColorPicker.js +2 -2
  96. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +2 -3
  97. package/dist/cjs/DragAndDrop/DragButton.js +5 -3
  98. package/dist/cjs/Drawer/Drawer.js +1 -1
  99. package/dist/cjs/EChart/EChart.js +3 -4
  100. package/dist/cjs/GaugeChart/GaugeChart.js +2 -5
  101. package/dist/cjs/InfoTooltip/InfoTooltip.js +5 -4
  102. package/dist/cjs/Legend/ListLegendItem.js +3 -4
  103. package/dist/cjs/LineChart/LineChart.js +4 -8
  104. package/dist/cjs/LinksEditor/LinksEditor.js +9 -18
  105. package/dist/cjs/Overlay/Overlay.js +1 -1
  106. package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +1 -2
  107. package/dist/cjs/StatChart/StatChart.js +11 -17
  108. package/dist/cjs/StatChart/calculateFontSize.js +2 -4
  109. package/dist/cjs/StatChart/utils/formatStatChartValue.js +34 -0
  110. package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +11 -28
  111. package/dist/cjs/StatusHistoryChart/StatusHistoryTooltip.js +3 -3
  112. package/dist/cjs/StatusHistoryChart/utils/get-color.js +7 -7
  113. package/dist/cjs/Table/Table.js +5 -5
  114. package/dist/cjs/Table/TableCell.js +5 -6
  115. package/dist/cjs/Table/VirtualizedTable.js +11 -14
  116. package/dist/cjs/Table/hooks/useTableKeyboardNav.js +1 -1
  117. package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +7 -13
  118. package/dist/cjs/Table/model/table-model.js +1 -1
  119. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +15 -23
  120. package/dist/cjs/TimeChart/TimeChart.js +3 -6
  121. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +6 -11
  122. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +1 -2
  123. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +2 -3
  124. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +4 -10
  125. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +13 -23
  126. package/dist/cjs/TimeSeriesTooltip/utils.js +2 -4
  127. package/dist/cjs/TransformsEditor/TransformEditor.js +4 -7
  128. package/dist/cjs/TransformsEditor/TransformEditorContainer.js +3 -5
  129. package/dist/cjs/TransformsEditor/TransformsEditor.js +3 -6
  130. package/dist/cjs/ValueMappingEditor/ValueMappingEditor.js +387 -0
  131. package/dist/cjs/ValueMappingEditor/ValueMappingsEditor.js +131 -0
  132. package/dist/cjs/ValueMappingEditor/index.js +30 -0
  133. package/dist/cjs/context/TimeZoneProvider.js +1 -1
  134. package/dist/cjs/controls/TextField.js +1 -1
  135. package/dist/cjs/index.js +1 -0
  136. package/dist/cjs/utils/chart-actions.js +1 -2
  137. package/dist/cjs/utils/format.js +1 -1
  138. package/dist/cjs/utils/theme-gen.js +5 -7
  139. package/dist/context/TimeZoneProvider.js +1 -1
  140. package/dist/context/TimeZoneProvider.js.map +1 -1
  141. package/dist/controls/TextField.js +1 -1
  142. package/dist/controls/TextField.js.map +1 -1
  143. package/dist/index.d.ts +1 -0
  144. package/dist/index.d.ts.map +1 -1
  145. package/dist/index.js +1 -0
  146. package/dist/index.js.map +1 -1
  147. package/dist/utils/chart-actions.js +1 -2
  148. package/dist/utils/chart-actions.js.map +1 -1
  149. package/dist/utils/format.js +1 -1
  150. package/dist/utils/format.js.map +1 -1
  151. package/dist/utils/theme-gen.js +5 -7
  152. package/dist/utils/theme-gen.js.map +1 -1
  153. package/package.json +3 -3
@@ -36,7 +36,7 @@ const Drawer = ({ anchor = 'right', isOpen, onClose, PaperProps, children, ...re
36
36
  sx: (0, _utils.combineSx)({
37
37
  width: isSmaller ? '100%' : `${DRAWER_DEFAULT_WIDTH}px`,
38
38
  overflow: 'hidden'
39
- }, PaperProps === null || PaperProps === void 0 ? void 0 : PaperProps.sx)
39
+ }, PaperProps?.sx)
40
40
  },
41
41
  children: children
42
42
  });
@@ -56,11 +56,11 @@ const EChart = /*#__PURE__*/ (0, _react.memo)(function EChart({ option, theme, r
56
56
  (0, _react.useLayoutEffect)(()=>{
57
57
  if (containerRef.current === null || chartElement.current !== null) return;
58
58
  chartElement.current = (0, _core.init)(containerRef.current, theme, {
59
- renderer: renderer !== null && renderer !== void 0 ? renderer : 'canvas'
59
+ renderer: renderer ?? 'canvas'
60
60
  });
61
61
  if (chartElement.current === undefined) return;
62
62
  chartElement.current.setOption(initialOption.current, true);
63
- onChartInitialized === null || onChartInitialized === void 0 ? void 0 : onChartInitialized(chartElement.current);
63
+ onChartInitialized?.(chartElement.current);
64
64
  if (_instance !== undefined) {
65
65
  _instance.current = chartElement.current;
66
66
  }
@@ -160,8 +160,7 @@ function bindEvents(instance, events) {
160
160
  }
161
161
  for(const eventName in events){
162
162
  if (Object.prototype.hasOwnProperty.call(events, eventName)) {
163
- var _events_eventName;
164
- const customEvent = (_events_eventName = events[eventName]) !== null && _events_eventName !== void 0 ? _events_eventName : null;
163
+ const customEvent = events[eventName] ?? null;
165
164
  if (customEvent) {
166
165
  bindEvent(eventName, customEvent);
167
166
  }
@@ -51,11 +51,9 @@ function GaugeChart(props) {
51
51
  const chartsTheme = (0, _context.useChartsTheme)();
52
52
  // useDeepMemo ensures value size util does not rerun everytime you hover on the chart
53
53
  const option = (0, _core.useDeepMemo)(()=>{
54
- var _chartsTheme_echartsTheme_textStyle;
55
54
  if (data.value === undefined) return chartsTheme.noDataOption;
56
55
  // adjusts fontSize depending on number of characters
57
56
  const valueSizeClamp = getResponsiveValueSize(data.value, format, width, height);
58
- var _chartsTheme_echartsTheme_textStyle_color;
59
57
  return {
60
58
  title: {
61
59
  show: false
@@ -185,7 +183,7 @@ function GaugeChart(props) {
185
183
  // https://echarts.apache.org/en/option.html#series-gauge.data.title
186
184
  title: {
187
185
  show: true,
188
- color: (_chartsTheme_echartsTheme_textStyle_color = (_chartsTheme_echartsTheme_textStyle = chartsTheme.echartsTheme.textStyle) === null || _chartsTheme_echartsTheme_textStyle === void 0 ? void 0 : _chartsTheme_echartsTheme_textStyle.color) !== null && _chartsTheme_echartsTheme_textStyle_color !== void 0 ? _chartsTheme_echartsTheme_textStyle_color : 'inherit',
186
+ color: chartsTheme.echartsTheme.textStyle?.color ?? 'inherit',
189
187
  offsetCenter: [
190
188
  0,
191
189
  '55%'
@@ -223,8 +221,7 @@ function getResponsiveValueSize(value, format, width, height) {
223
221
  const MAX_SIZE = 24;
224
222
  const SIZE_MULTIPLIER = 0.7;
225
223
  const formattedValue = typeof value === 'number' ? (0, _core.formatValue)(value, format) : `${value}`;
226
- var _formattedValue_length;
227
- const valueCharacters = (_formattedValue_length = formattedValue.length) !== null && _formattedValue_length !== void 0 ? _formattedValue_length : 2;
224
+ const valueCharacters = formattedValue.length ?? 2;
228
225
  const valueSize = Math.min(width, height) / valueCharacters * SIZE_MULTIPLIER;
229
226
  return `clamp(${MIN_SIZE}px, ${valueSize}px, ${MAX_SIZE}px)`;
230
227
  }
@@ -35,13 +35,13 @@ const InfoTooltip = ({ id, title, description, placement, children, enterDelay,
35
35
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(StyledTooltip, {
36
36
  arrow: true,
37
37
  id: id,
38
- placement: placement !== null && placement !== void 0 ? placement : 'top',
38
+ placement: placement ?? 'top',
39
39
  title: /*#__PURE__*/ (0, _jsxruntime.jsx)(TooltipContent, {
40
40
  title: title,
41
41
  description: description
42
42
  }),
43
- enterDelay: enterDelay !== null && enterDelay !== void 0 ? enterDelay : 500,
44
- enterNextDelay: enterNextDelay !== null && enterNextDelay !== void 0 ? enterNextDelay : 500,
43
+ enterDelay: enterDelay ?? 500,
44
+ enterNextDelay: enterNextDelay ?? 500,
45
45
  children: wrappedChildren
46
46
  });
47
47
  };
@@ -59,7 +59,8 @@ const TooltipContent = ({ title, description })=>{
59
59
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
60
60
  variant: "caption",
61
61
  sx: (theme)=>({
62
- color: theme.palette.text.primary
62
+ color: theme.palette.text.primary,
63
+ whiteSpace: 'pre-line'
63
64
  }),
64
65
  children: description
65
66
  })
@@ -38,9 +38,8 @@ const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLeg
38
38
  }
39
39
  }
40
40
  const handleClick = (e)=>{
41
- var _item_onClick;
42
41
  onClick(e, item.id);
43
- (_item_onClick = item.onClick) === null || _item_onClick === void 0 ? void 0 : _item_onClick.call(item, e);
42
+ item.onClick?.(e);
44
43
  };
45
44
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.ListItemButton, {
46
45
  ...others,
@@ -51,11 +50,11 @@ const ListLegendItemBase = /*#__PURE__*/ (0, _react.forwardRef)(function ListLeg
51
50
  }, sx),
52
51
  dense: true,
53
52
  onClick: handleClick,
54
- onMouseOver: (e)=>onMouseOver === null || onMouseOver === void 0 ? void 0 : onMouseOver(e, {
53
+ onMouseOver: (e)=>onMouseOver?.(e, {
55
54
  id: item.id,
56
55
  index
57
56
  }),
58
- onMouseOut: (e)=>onMouseOut === null || onMouseOut === void 0 ? void 0 : onMouseOut(e, {
57
+ onMouseOut: (e)=>onMouseOut?.(e, {
59
58
  id: item.id,
60
59
  index
61
60
  }),
@@ -45,7 +45,6 @@ const _utils = require("../utils");
45
45
  _renderers.CanvasRenderer
46
46
  ]);
47
47
  const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ height, data, yAxis, format, grid, legend, tooltipConfig = _TimeSeriesTooltip.DEFAULT_TOOLTIP_CONFIG, noDataVariant = 'message', syncGroup, onDataZoom, onDoubleClick, __experimentalEChartsOptionsOverride }, ref) {
48
- var _option_tooltip;
49
48
  const chartsTheme = (0, _context.useChartsTheme)();
50
49
  const chartRef = (0, _react.useRef)();
51
50
  const [showTooltip, setShowTooltip] = (0, _react.useState)(true);
@@ -84,10 +83,8 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
84
83
  }, 10);
85
84
  }
86
85
  if (onDataZoom === undefined || params.batch[0] === undefined) return;
87
- var _params_batch__startValue;
88
- const startIndex = (_params_batch__startValue = params.batch[0].startValue) !== null && _params_batch__startValue !== void 0 ? _params_batch__startValue : 0;
89
- var _params_batch__endValue;
90
- const endIndex = (_params_batch__endValue = params.batch[0].endValue) !== null && _params_batch__endValue !== void 0 ? _params_batch__endValue : data.xAxis.length - 1;
86
+ const startIndex = params.batch[0].startValue ?? 0;
87
+ const endIndex = params.batch[0].endValue ?? data.xAxis.length - 1;
91
88
  const xAxisStartValue = data.xAxis[startIndex];
92
89
  const xAxisEndValue = data.xAxis[endIndex];
93
90
  if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {
@@ -115,8 +112,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
115
112
  // The "chart" `noDataVariant` is only used when the `timeSeries` is an
116
113
  // empty array because a `null` value will throw an error.
117
114
  if (data.timeSeries === null || data.timeSeries.length === 0 && noDataVariant === 'message') return noDataOption;
118
- var _data_rangeMs;
119
- const rangeMs = (_data_rangeMs = data.rangeMs) !== null && _data_rangeMs !== void 0 ? _data_rangeMs : (0, _utils.getDateRange)(data.xAxis);
115
+ const rangeMs = data.rangeMs ?? (0, _utils.getDateRange)(data.xAxis);
120
116
  const option = {
121
117
  series: data.timeSeries,
122
118
  xAxis: {
@@ -250,7 +246,7 @@ const LineChart = /*#__PURE__*/ (0, _react.forwardRef)(function LineChart({ heig
250
246
  }
251
247
  },
252
248
  children: [
253
- showTooltip === true && ((_option_tooltip = option.tooltip) === null || _option_tooltip === void 0 ? void 0 : _option_tooltip.showContent) === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesTooltip.LineChartTooltip, {
249
+ showTooltip === true && option.tooltip?.showContent === false && tooltipConfig.hidden !== true && /*#__PURE__*/ (0, _jsxruntime.jsx)(_TimeSeriesTooltip.LineChartTooltip, {
254
250
  chartRef: chartRef,
255
251
  chartData: data,
256
252
  wrapLabels: tooltipConfig.wrapLabels,
@@ -94,56 +94,47 @@ function LinkControl({ control, index }) {
94
94
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
95
95
  control: control,
96
96
  name: `panelDefinition.spec.links.${index}.url`,
97
- render: ({ field, fieldState })=>{
98
- var _fieldState_error;
99
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
97
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
100
98
  ...field,
101
99
  required: true,
102
100
  fullWidth: true,
103
101
  label: "URL",
104
102
  error: !!fieldState.error,
105
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
103
+ helperText: fieldState.error?.message,
106
104
  onChange: (event)=>{
107
105
  field.onChange(event);
108
106
  }
109
- });
110
- }
107
+ })
111
108
  }),
112
109
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
113
110
  control: control,
114
111
  name: `panelDefinition.spec.links.${index}.name`,
115
- render: ({ field, fieldState })=>{
116
- var _fieldState_error;
117
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
112
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
118
113
  ...field,
119
114
  fullWidth: true,
120
115
  label: "Name",
121
116
  defaultValue: "",
122
117
  error: !!fieldState.error,
123
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
118
+ helperText: fieldState.error?.message,
124
119
  onChange: (event)=>{
125
120
  field.onChange(event);
126
121
  }
127
- });
128
- }
122
+ })
129
123
  }),
130
124
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_reacthookform.Controller, {
131
125
  control: control,
132
126
  name: `panelDefinition.spec.links.${index}.tooltip`,
133
- render: ({ field, fieldState })=>{
134
- var _fieldState_error;
135
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
127
+ render: ({ field, fieldState })=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
136
128
  ...field,
137
129
  fullWidth: true,
138
130
  label: "Tooltip",
139
131
  defaultValue: "",
140
132
  error: !!fieldState.error,
141
- helperText: (_fieldState_error = fieldState.error) === null || _fieldState_error === void 0 ? void 0 : _fieldState_error.message,
133
+ helperText: fieldState.error?.message,
142
134
  onChange: (event)=>{
143
135
  field.onChange(event);
144
136
  }
145
- });
146
- }
137
+ })
147
138
  })
148
139
  ]
149
140
  }),
@@ -59,7 +59,7 @@ function LoadingOverlay(props) {
59
59
  height: '100%',
60
60
  alignItems: 'center',
61
61
  justifyContent: 'center',
62
- padding: '0 10px'
62
+ px: 1
63
63
  },
64
64
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Skeleton, {
65
65
  variant: variant,
@@ -26,8 +26,7 @@ function SettingsAutocomplete({ options, renderInput = (params)=>/*#__PURE__*/ (
26
26
  ...params
27
27
  }), ...otherProps }) {
28
28
  const getOptionLabel = (option)=>{
29
- var _option_label;
30
- return (_option_label = option.label) !== null && _option_label !== void 0 ? _option_label : option.id;
29
+ return option.label ?? option.id;
31
30
  };
32
31
  // Note: this component currently is not virtualized because it is specific
33
32
  // to being used for settings, which generally have a pretty small list of
@@ -22,22 +22,22 @@ Object.defineProperty(exports, "StatChart", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _react = require("react");
25
- const _core = require("@perses-dev/core");
26
25
  const _material = require("@mui/material");
27
26
  const _merge = /*#__PURE__*/ _interop_require_default(require("lodash/merge"));
28
- const _core1 = require("echarts/core");
27
+ const _core = require("echarts/core");
29
28
  const _charts = require("echarts/charts");
30
29
  const _components = require("echarts/components");
31
30
  const _renderers = require("echarts/renderers");
32
31
  const _context = require("../context");
33
32
  const _EChart = require("../EChart");
34
33
  const _calculateFontSize = require("./calculateFontSize");
34
+ const _formatStatChartValue = require("./utils/formatStatChartValue");
35
35
  function _interop_require_default(obj) {
36
36
  return obj && obj.__esModule ? obj : {
37
37
  default: obj
38
38
  };
39
39
  }
40
- (0, _core1.use)([
40
+ (0, _core.use)([
41
41
  _charts.LineChart,
42
42
  _components.GridComponent,
43
43
  _components.DatasetComponent,
@@ -49,21 +49,15 @@ const LINE_HEIGHT = 1.2;
49
49
  const SERIES_NAME_MAX_FONT_SIZE = 30;
50
50
  const SERIES_NAME_FONT_WEIGHT = 400;
51
51
  const VALUE_FONT_WEIGHT = 700;
52
- function StatChart(props) {
53
- var _data_seriesData, _data_seriesData1;
54
- const { width, height, data, format, color, sparkline, showSeriesName, valueFontSize } = props;
52
+ const StatChart = (props)=>{
53
+ const { width, height, data, sparkline, showSeriesName, format, valueFontSize } = props;
55
54
  const chartsTheme = (0, _context.useChartsTheme)();
56
- let formattedValue = '';
57
- if (data.calculatedValue === null) {
58
- formattedValue = 'null';
59
- } else if (typeof data.calculatedValue === 'number') {
60
- formattedValue = (0, _core.formatValue)(data.calculatedValue, format);
61
- }
55
+ const color = data.color;
56
+ const formattedValue = (0, _formatStatChartValue.formatStatChartValue)(data.calculatedValue, format);
62
57
  const containerPadding = chartsTheme.container.padding.default;
63
- var _data_seriesData_name;
64
58
  // calculate series name font size and height
65
59
  let seriesNameFontSize = (0, _calculateFontSize.useOptimalFontSize)({
66
- text: (_data_seriesData_name = data === null || data === void 0 ? void 0 : (_data_seriesData = data.seriesData) === null || _data_seriesData === void 0 ? void 0 : _data_seriesData.name) !== null && _data_seriesData_name !== void 0 ? _data_seriesData_name : '',
60
+ text: data?.seriesData?.name ?? '',
67
61
  fontWeight: SERIES_NAME_FONT_WEIGHT,
68
62
  width,
69
63
  height: height * 0.125,
@@ -162,7 +156,7 @@ function StatChart(props) {
162
156
  showSeriesName && /*#__PURE__*/ (0, _jsxruntime.jsx)(SeriesName, {
163
157
  padding: containerPadding,
164
158
  fontSize: seriesNameFontSize,
165
- children: (_data_seriesData1 = data.seriesData) === null || _data_seriesData1 === void 0 ? void 0 : _data_seriesData1.name
159
+ children: data.seriesData?.name
166
160
  }),
167
161
  /*#__PURE__*/ (0, _jsxruntime.jsx)(Value, {
168
162
  variant: "h3",
@@ -182,7 +176,7 @@ function StatChart(props) {
182
176
  })
183
177
  ]
184
178
  });
185
- }
179
+ };
186
180
  const SeriesName = (0, _material.styled)(_material.Typography, {
187
181
  shouldForwardProp: (prop)=>prop !== 'padding' && prop !== 'fontSize'
188
182
  })(({ theme, padding, fontSize })=>({
@@ -196,7 +190,7 @@ const SeriesName = (0, _material.styled)(_material.Typography, {
196
190
  const Value = (0, _material.styled)(_material.Typography, {
197
191
  shouldForwardProp: (prop)=>prop !== 'color' && prop !== 'padding' && prop !== 'fontSize' && prop !== 'sparkline'
198
192
  })(({ theme, color, padding, fontSize, sparkline })=>({
199
- color: color !== null && color !== void 0 ? color : theme.palette.text.primary,
193
+ color: color ?? theme.palette.text.primary,
200
194
  fontSize: `${fontSize}px`,
201
195
  padding: sparkline ? `${padding}px ${padding}px 0 ${padding}px` : ` 0 ${padding}px`,
202
196
  whiteSpace: 'nowrap',
@@ -39,10 +39,8 @@ function useOptimalFontSize({ text, fontWeight, width, height, lineHeight, maxSi
39
39
  return Number(fontSizeOverride);
40
40
  }
41
41
  const textStyle = echartsTheme.textStyle;
42
- var _Number;
43
- const fontSize = (_Number = Number(textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontSize)) !== null && _Number !== void 0 ? _Number : 12;
44
- var _textStyle_fontFamily;
45
- const fontFamily = (_textStyle_fontFamily = textStyle === null || textStyle === void 0 ? void 0 : textStyle.fontFamily) !== null && _textStyle_fontFamily !== void 0 ? _textStyle_fontFamily : 'Lato';
42
+ const fontSize = Number(textStyle?.fontSize) ?? 12;
43
+ const fontFamily = textStyle?.fontFamily ?? 'Lato';
46
44
  // set the font on the canvas context
47
45
  const fontStyle = `${fontWeight} ${fontSize}px ${fontFamily}`;
48
46
  ctx.font = fontStyle;
@@ -0,0 +1,34 @@
1
+ // Copyright 2024 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, "formatStatChartValue", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return formatStatChartValue;
21
+ }
22
+ });
23
+ const _core = require("@perses-dev/core");
24
+ const formatStatChartValue = (value, format)=>{
25
+ if (value === null) {
26
+ return 'null';
27
+ } else if (typeof value === 'number') {
28
+ return (0, _core.formatValue)(value, format);
29
+ } else if (value === undefined) {
30
+ return '';
31
+ } else {
32
+ return value;
33
+ }
34
+ };
@@ -26,10 +26,9 @@ const _charts = require("echarts/charts");
26
26
  const _components = require("echarts/components");
27
27
  const _core = require("echarts/core");
28
28
  const _renderers = require("echarts/renderers");
29
- const _react = require("react");
30
- const _context = require("../context");
29
+ const _ChartsProvider = require("../context/ChartsProvider");
30
+ const _TimeZoneProvider = require("../context/TimeZoneProvider");
31
31
  const _EChart = require("../EChart");
32
- const _getcolor = require("./utils/get-color");
33
32
  const _getformattedaxislabel = require("./get-formatted-axis-label");
34
33
  const _StatusHistoryTooltip = require("./StatusHistoryTooltip");
35
34
  (0, _core.use)([
@@ -41,34 +40,18 @@ const _StatusHistoryTooltip = require("./StatusHistoryTooltip");
41
40
  _components.TooltipComponent,
42
41
  _renderers.CanvasRenderer
43
42
  ]);
44
- function StatusHistoryChart(props) {
45
- const { height, data, xAxisCategories, yAxisCategories, timeScale } = props;
46
- const { timeZone } = (0, _context.useTimeZone)();
47
- const chartsTheme = (0, _context.useChartsTheme)();
43
+ const StatusHistoryChart = (props)=>{
44
+ const { height, data, xAxisCategories, yAxisCategories, timeScale, colors } = props;
45
+ const { timeZone } = (0, _TimeZoneProvider.useTimeZone)();
46
+ const chartsTheme = (0, _ChartsProvider.useChartsTheme)();
48
47
  const theme = (0, _material.useTheme)();
49
- const uniqueValues = (0, _react.useMemo)(()=>[
50
- ...new Set(data.map((item)=>item[2]))
51
- ].filter((value)=>value !== undefined), [
52
- data
53
- ]);
54
- // get colors from theme and generate colors if not provided
55
- const pieces = (0, _react.useMemo)(()=>{
56
- const themeColors = Array.isArray(chartsTheme.echartsTheme.color) ? chartsTheme.echartsTheme.color.filter((color)=>typeof color === 'string') : [];
57
- return uniqueValues.map((value, index)=>({
58
- value,
59
- color: (0, _getcolor.getColorsForValues)(uniqueValues, themeColors)[index]
60
- }));
61
- }, [
62
- uniqueValues,
63
- chartsTheme.echartsTheme.color
64
- ]);
65
- var _timeScale_rangeMs;
66
48
  const option = {
67
49
  tooltip: {
68
50
  appendToBody: true,
69
51
  formatter: (params)=>{
70
52
  return (0, _StatusHistoryTooltip.generateTooltipHTML)({
71
- data: params.data,
53
+ data: params.data.value,
54
+ label: params.data.label,
72
55
  marker: params.marker,
73
56
  xAxisCategories,
74
57
  yAxisCategories,
@@ -91,7 +74,7 @@ function StatusHistoryChart(props) {
91
74
  },
92
75
  axisLabel: {
93
76
  hideOverlap: true,
94
- formatter: (0, _getformattedaxislabel.getFormattedStatusHistoryAxisLabel)((_timeScale_rangeMs = timeScale === null || timeScale === void 0 ? void 0 : timeScale.rangeMs) !== null && _timeScale_rangeMs !== void 0 ? _timeScale_rangeMs : 0, timeZone)
77
+ formatter: (0, _getformattedaxislabel.getFormattedStatusHistoryAxisLabel)(timeScale?.rangeMs ?? 0, timeZone)
95
78
  }
96
79
  },
97
80
  yAxis: {
@@ -114,7 +97,7 @@ function StatusHistoryChart(props) {
114
97
  visualMap: {
115
98
  show: false,
116
99
  type: 'piecewise',
117
- pieces
100
+ pieces: colors
118
101
  },
119
102
  series: [
120
103
  {
@@ -154,4 +137,4 @@ function StatusHistoryChart(props) {
154
137
  theme: chartsTheme.echartsTheme
155
138
  })
156
139
  });
157
- }
140
+ };
@@ -22,8 +22,8 @@ Object.defineProperty(exports, "generateTooltipHTML", {
22
22
  });
23
23
  const _material = require("@mui/material");
24
24
  const _utils = require("../utils");
25
- function generateTooltipHTML({ data, marker, xAxisCategories, yAxisCategories, theme }) {
26
- const [x, y, value] = data;
25
+ function generateTooltipHTML({ data, label, marker, xAxisCategories, yAxisCategories, theme }) {
26
+ const [x, y] = data;
27
27
  const xAxisLabel = xAxisCategories[x];
28
28
  const { formattedDate, formattedTime } = (0, _utils.getDateAndTime)(xAxisLabel);
29
29
  const tooltipHeader = (0, _material.css)`
@@ -47,7 +47,7 @@ function generateTooltipHTML({ data, marker, xAxisCategories, yAxisCategories, t
47
47
  <strong>${yAxisCategories[y]}</strong>
48
48
  </div>
49
49
  <div>
50
- ${value}
50
+ ${label}
51
51
  </div>
52
52
  </div>
53
53
  </div>
@@ -21,8 +21,8 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- fallbackColor: function() {
25
- return fallbackColor;
24
+ FALLBACK_COLOR: function() {
25
+ return FALLBACK_COLOR;
26
26
  },
27
27
  getColorForValue: function() {
28
28
  return getColorForValue;
@@ -37,11 +37,11 @@ _export(exports, {
37
37
  return hslToHex;
38
38
  }
39
39
  });
40
- const fallbackColor = '#1f77b4';
40
+ const FALLBACK_COLOR = '#1f77b4';
41
41
  function getColorForValue(value, baseColor) {
42
42
  // Validate base color
43
43
  if (!baseColor.match(/^#[0-9A-Fa-f]{6}$/)) {
44
- baseColor = fallbackColor;
44
+ baseColor = FALLBACK_COLOR;
45
45
  }
46
46
  try {
47
47
  const [baseH, baseS, baseL] = hexToHSL(baseColor);
@@ -66,7 +66,7 @@ function getColorForValue(value, baseColor) {
66
66
  }
67
67
  return color;
68
68
  } catch (_) {
69
- return fallbackColor;
69
+ return FALLBACK_COLOR;
70
70
  }
71
71
  }
72
72
  function getColorsForValues(uniqueValues, themeColors) {
@@ -77,9 +77,9 @@ function getColorsForValues(uniqueValues, themeColors) {
77
77
  // Use theme colors first, then generate additional ones
78
78
  return uniqueValues.map((value, index)=>{
79
79
  if (index < themeColors.length) {
80
- return themeColors[index] || fallbackColor;
80
+ return themeColors[index] || FALLBACK_COLOR;
81
81
  }
82
- return getColorForValue(value, themeColors[0] || fallbackColor);
82
+ return getColorForValue(value, themeColors[0] || FALLBACK_COLOR);
83
83
  });
84
84
  }
85
85
  function hexToHSL(hex) {
@@ -39,7 +39,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
39
39
  const theme = (0, _material.useTheme)();
40
40
  const handleRowSelectionChange = (rowSelectionUpdater)=>{
41
41
  const newRowSelection = typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;
42
- onRowSelectionChange === null || onRowSelectionChange === void 0 ? void 0 : onRowSelectionChange(newRowSelection);
42
+ onRowSelectionChange?.(newRowSelection);
43
43
  };
44
44
  const handleRowSelectionEvent = (0, _react.useCallback)((table, row, isModified)=>{
45
45
  if (rowSelectionVariant === 'standard' || isModified) {
@@ -53,7 +53,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
53
53
  table.toggleAllRowsSelected();
54
54
  } else {
55
55
  // Focus the selected row.
56
- onRowSelectionChange === null || onRowSelectionChange === void 0 ? void 0 : onRowSelectionChange({
56
+ onRowSelectionChange?.({
57
57
  [row.id]: true
58
58
  });
59
59
  }
@@ -64,14 +64,14 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
64
64
  ]);
65
65
  const handleCheckboxChange = (0, _react.useCallback)((e, table, row)=>{
66
66
  const nativePointerEvent = e.nativeEvent && (e.nativeEvent instanceof MouseEvent || e.nativeEvent instanceof KeyboardEvent) ? e.nativeEvent : undefined;
67
- const isModifed = !!(nativePointerEvent === null || nativePointerEvent === void 0 ? void 0 : nativePointerEvent.metaKey) || !!(nativePointerEvent === null || nativePointerEvent === void 0 ? void 0 : nativePointerEvent.shiftKey);
67
+ const isModifed = !!nativePointerEvent?.metaKey || !!nativePointerEvent?.shiftKey;
68
68
  handleRowSelectionEvent(table, row, isModifed);
69
69
  }, [
70
70
  handleRowSelectionEvent
71
71
  ]);
72
72
  const handleSortingChange = (sortingUpdater)=>{
73
73
  const newSorting = typeof sortingUpdater === 'function' ? sortingUpdater(sorting) : sortingUpdater;
74
- onSortingChange === null || onSortingChange === void 0 ? void 0 : onSortingChange(newSorting);
74
+ onSortingChange?.(newSorting);
75
75
  };
76
76
  const checkboxColumn = (0, _react.useMemo)(()=>{
77
77
  return {
@@ -93,7 +93,7 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
93
93
  onChange: (e)=>{
94
94
  handleCheckboxChange(e, table, row);
95
95
  },
96
- color: getCheckboxColor === null || getCheckboxColor === void 0 ? void 0 : getCheckboxColor(row.original),
96
+ color: getCheckboxColor?.(row.original),
97
97
  density: density
98
98
  });
99
99
  },
@@ -51,9 +51,8 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
51
51
  focusState
52
52
  ]);
53
53
  const handleFocus = (e)=>{
54
- var _e_currentTarget;
55
54
  // From https://zellwk.com/blog/keyboard-focusable-elements/
56
- const nestedFocusTarget = (_e_currentTarget = e.currentTarget) === null || _e_currentTarget === void 0 ? void 0 : _e_currentTarget.querySelector('a[href], button, input, textarea, select, details,[role="button"]');
55
+ const nestedFocusTarget = e.currentTarget?.querySelector('a[href], button, input, textarea, select, details,[role="button"]');
57
56
  if (nestedFocusTarget) {
58
57
  // If the cell has a focusable child, focus it instead. Mostly used for
59
58
  // checkbox cells, but could have other uses.
@@ -66,7 +65,7 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
66
65
  // plays with the triggering of focus with keyboard interactions.
67
66
  // These report that a focus event happened, so we can adjust the current
68
67
  // tabindex and focuses to the right cell.
69
- onFocusTrigger === null || onFocusTrigger === void 0 ? void 0 : onFocusTrigger(e);
68
+ onFocusTrigger?.(e);
70
69
  };
71
70
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(StyledMuiTableCell, {
72
71
  ...otherProps,
@@ -93,7 +92,7 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
93
92
  minWidth: '100%',
94
93
  whiteSpace: 'nowrap',
95
94
  overflow: 'visible',
96
- backgroundColor: `${backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : theme.palette.background.default} !important`,
95
+ backgroundColor: `${backgroundColor ?? theme.palette.background.default} !important`,
97
96
  outline: `solid 1px ${theme.palette.info.main}`,
98
97
  outlineOffset: '-1px'
99
98
  }
@@ -118,8 +117,8 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
118
117
  flexDirection: 'inherit'
119
118
  },
120
119
  style: {
121
- backgroundColor: backgroundColor !== null && backgroundColor !== void 0 ? backgroundColor : 'inherit',
122
- color: color !== null && color !== void 0 ? color : 'inherit'
120
+ backgroundColor: backgroundColor ?? 'inherit',
121
+ color: color ?? 'inherit'
123
122
  },
124
123
  title: description,
125
124
  "aria-label": description,