@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
@@ -35,14 +35,12 @@ function _interop_require_default(obj) {
35
35
  };
36
36
  }
37
37
  function TransformEditorContainer({ index, value, isCollapsed, onChange, onCollapse, onDelete, ...props }) {
38
- var _value_spec, _value_spec1;
39
38
  function handleTransformDisable() {
40
- var _value_spec;
41
39
  onChange({
42
40
  ...value,
43
41
  spec: {
44
42
  ...value.spec,
45
- disabled: !((_value_spec = value.spec) === null || _value_spec === void 0 ? void 0 : _value_spec.disabled)
43
+ disabled: !value.spec?.disabled
46
44
  }
47
45
  });
48
46
  }
@@ -90,7 +88,7 @@ function TransformEditorContainer({ index, value, isCollapsed, onChange, onColla
90
88
  isCollapsed && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
91
89
  children: [
92
90
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tooltip, {
93
- title: ((_value_spec = value.spec) === null || _value_spec === void 0 ? void 0 : _value_spec.disabled) ? 'Enable transformation' : 'Disable transformation',
91
+ title: value.spec?.disabled ? 'Enable transformation' : 'Disable transformation',
94
92
  placement: "top",
95
93
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
96
94
  size: "small",
@@ -98,7 +96,7 @@ function TransformEditorContainer({ index, value, isCollapsed, onChange, onColla
98
96
  marginLeft: 'auto'
99
97
  },
100
98
  onClick: handleTransformDisable,
101
- children: ((_value_spec1 = value.spec) === null || _value_spec1 === void 0 ? void 0 : _value_spec1.disabled) ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_EyeOffOutline.default, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_EyeOutline.default, {})
99
+ children: value.spec?.disabled ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_EyeOffOutline.default, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_EyeOutline.default, {})
102
100
  })
103
101
  }),
104
102
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {
@@ -81,17 +81,14 @@ function TransformsEditor({ value, onChange, ...props }) {
81
81
  gap: 1,
82
82
  ...props,
83
83
  children: [
84
- value.map((transform, i)=>{
85
- var _transformsCollapsed_i;
86
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_TransformEditorContainer.TransformEditorContainer, {
84
+ value.map((transform, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_TransformEditorContainer.TransformEditorContainer, {
87
85
  index: i,
88
86
  value: transform,
89
- isCollapsed: (_transformsCollapsed_i = transformsCollapsed[i]) !== null && _transformsCollapsed_i !== void 0 ? _transformsCollapsed_i : true,
87
+ isCollapsed: transformsCollapsed[i] ?? true,
90
88
  onChange: (updatedTransform)=>handleTransformChange(i, updatedTransform),
91
89
  onDelete: ()=>handleTransformDelete(i),
92
90
  onCollapse: (collapsed)=>handleTransformCollapseExpand(i, collapsed)
93
- }, i);
94
- }),
91
+ }, i)),
95
92
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
96
93
  variant: "contained",
97
94
  startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {}),
@@ -0,0 +1,387 @@
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, "ValueMappingEditor", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return ValueMappingEditor;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _DeleteOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DeleteOutline"));
26
+ const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
27
+ const _OptionsColorPicker = require("../ColorPicker/OptionsColorPicker");
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ const ConditionEditor = ({ mapping, onChange, ...props })=>{
34
+ switch(mapping.kind){
35
+ case 'Value':
36
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
37
+ gap: 1,
38
+ direction: "row",
39
+ ...props,
40
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
41
+ label: "Value",
42
+ placeholder: "Exact value",
43
+ value: mapping.spec?.value ?? '',
44
+ onChange: (e)=>onChange({
45
+ ...mapping,
46
+ spec: {
47
+ ...mapping.spec,
48
+ value: e.target.value
49
+ }
50
+ }),
51
+ fullWidth: true
52
+ })
53
+ });
54
+ case 'Range':
55
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
56
+ gap: 1,
57
+ direction: "row",
58
+ ...props,
59
+ children: [
60
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
61
+ label: "From",
62
+ placeholder: "Start of range",
63
+ value: mapping.spec?.from ?? '',
64
+ onChange: (e)=>onChange({
65
+ ...mapping,
66
+ spec: {
67
+ ...mapping.spec,
68
+ from: e.target.value === '' ? undefined : +e.target.value
69
+ }
70
+ }),
71
+ fullWidth: true
72
+ }),
73
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
74
+ label: "To",
75
+ placeholder: "End of range (inclusive)",
76
+ value: mapping.spec?.to ?? '',
77
+ onChange: (e)=>onChange({
78
+ ...mapping,
79
+ spec: {
80
+ ...mapping.spec,
81
+ to: e.target.value === '' ? undefined : +e.target.value
82
+ }
83
+ }),
84
+ fullWidth: true
85
+ })
86
+ ]
87
+ });
88
+ case 'Regex':
89
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
90
+ gap: 1,
91
+ direction: "row",
92
+ ...props,
93
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
94
+ label: "Regular Expression",
95
+ placeholder: "JavaScript regular expression",
96
+ value: mapping.spec?.pattern ?? '',
97
+ onChange: (e)=>onChange({
98
+ ...mapping,
99
+ spec: {
100
+ ...mapping.spec,
101
+ pattern: e.target.value
102
+ }
103
+ }),
104
+ fullWidth: true
105
+ })
106
+ });
107
+ case 'Misc':
108
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
109
+ gap: 1,
110
+ direction: "row",
111
+ ...props,
112
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
113
+ select: true,
114
+ label: "Value",
115
+ value: mapping.spec?.value ?? '',
116
+ onChange: (e)=>onChange({
117
+ ...mapping,
118
+ spec: {
119
+ value: e.target.value
120
+ }
121
+ }),
122
+ SelectProps: {
123
+ renderValue: (selected)=>{
124
+ switch(selected){
125
+ case 'empty':
126
+ return 'Empty';
127
+ case 'null':
128
+ return 'Null';
129
+ case 'NaN':
130
+ return 'NaN';
131
+ case 'true':
132
+ return 'True';
133
+ case 'false':
134
+ return 'False';
135
+ default:
136
+ return String(selected);
137
+ }
138
+ }
139
+ },
140
+ fullWidth: true,
141
+ children: [
142
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
143
+ value: "empty",
144
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
145
+ children: [
146
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
147
+ children: "Empty"
148
+ }),
149
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
150
+ variant: "caption",
151
+ children: "Matches empty string"
152
+ })
153
+ ]
154
+ })
155
+ }),
156
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
157
+ value: "null",
158
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
159
+ children: [
160
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
161
+ children: "Null"
162
+ }),
163
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
164
+ variant: "caption",
165
+ children: "Matches null or undefined"
166
+ })
167
+ ]
168
+ })
169
+ }),
170
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
171
+ value: "NaN",
172
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
173
+ children: [
174
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
175
+ children: "NaN"
176
+ }),
177
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
178
+ variant: "caption",
179
+ children: "Matches Not a Number value"
180
+ })
181
+ ]
182
+ })
183
+ }),
184
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
185
+ value: "true",
186
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
187
+ children: [
188
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
189
+ children: "True"
190
+ }),
191
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
192
+ variant: "caption",
193
+ children: "Matches true boolean"
194
+ })
195
+ ]
196
+ })
197
+ }),
198
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
199
+ value: "false",
200
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
201
+ children: [
202
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
203
+ children: "False"
204
+ }),
205
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
206
+ variant: "caption",
207
+ children: "Matches false boolean"
208
+ })
209
+ ]
210
+ })
211
+ })
212
+ ]
213
+ })
214
+ });
215
+ default:
216
+ return null;
217
+ }
218
+ };
219
+ const ValueMappingEditor = ({ mapping, onChange, onDelete, ...props })=>{
220
+ const handleColorChange = (color)=>{
221
+ onChange({
222
+ ...mapping,
223
+ spec: {
224
+ ...mapping.spec,
225
+ result: {
226
+ ...mapping.spec.result,
227
+ color
228
+ }
229
+ }
230
+ });
231
+ };
232
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid2, {
233
+ container: true,
234
+ spacing: 2,
235
+ ...props,
236
+ children: [
237
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
238
+ size: {
239
+ xs: 5
240
+ },
241
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
242
+ direction: "row",
243
+ gap: 1,
244
+ width: "100%",
245
+ children: [
246
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
247
+ select: true,
248
+ label: "Type",
249
+ value: mapping.kind,
250
+ onChange: (e)=>onChange({
251
+ ...mapping,
252
+ kind: e.target.value
253
+ }),
254
+ required: true,
255
+ sx: {
256
+ width: '120px'
257
+ },
258
+ children: [
259
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
260
+ value: "Value",
261
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
262
+ children: [
263
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
264
+ children: "Value"
265
+ }),
266
+ mapping.kind !== 'Value' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
267
+ variant: "caption",
268
+ children: "Matches an exact text value"
269
+ })
270
+ ]
271
+ })
272
+ }),
273
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
274
+ value: "Range",
275
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
276
+ children: [
277
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
278
+ children: "Range"
279
+ }),
280
+ mapping.kind !== 'Range' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
281
+ variant: "caption",
282
+ children: "Matches against a numerical range"
283
+ })
284
+ ]
285
+ })
286
+ }),
287
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
288
+ value: "Regex",
289
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
290
+ children: [
291
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
292
+ children: "Regex"
293
+ }),
294
+ mapping.kind !== 'Regex' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
295
+ variant: "caption",
296
+ children: "Matches against a regular expression"
297
+ })
298
+ ]
299
+ })
300
+ }),
301
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
302
+ value: "Misc",
303
+ children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
304
+ children: [
305
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
306
+ children: "Misc"
307
+ }),
308
+ mapping.kind !== 'Misc' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
309
+ variant: "caption",
310
+ children: "Matches against empty, null and NaN values"
311
+ })
312
+ ]
313
+ })
314
+ })
315
+ ]
316
+ }),
317
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(ConditionEditor, {
318
+ width: "100%",
319
+ mapping: mapping,
320
+ onChange: (updatedMapping)=>onChange({
321
+ ...mapping,
322
+ ...updatedMapping
323
+ })
324
+ })
325
+ ]
326
+ })
327
+ }),
328
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
329
+ size: {
330
+ xs: 4
331
+ },
332
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
333
+ label: "Display text",
334
+ value: mapping.spec?.result?.value ?? '',
335
+ onChange: (e)=>onChange({
336
+ ...mapping,
337
+ spec: {
338
+ ...mapping.spec,
339
+ result: {
340
+ ...mapping.spec?.result,
341
+ value: e.target.value
342
+ }
343
+ }
344
+ }),
345
+ fullWidth: true
346
+ })
347
+ }),
348
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
349
+ size: {
350
+ xs: 1
351
+ },
352
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
353
+ direction: "row",
354
+ justifyContent: "center",
355
+ gap: 1,
356
+ children: mapping.spec?.result?.color ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_OptionsColorPicker.OptionsColorPicker, {
357
+ label: "Color",
358
+ color: mapping.spec.result.color ?? '#000',
359
+ onColorChange: handleColorChange,
360
+ onClear: ()=>handleColorChange(undefined)
361
+ }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
362
+ onClick: ()=>handleColorChange('#000'),
363
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
364
+ })
365
+ })
366
+ }),
367
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
368
+ size: {
369
+ xs: 1
370
+ },
371
+ textAlign: "end",
372
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Tooltip, {
373
+ title: "Remove mapping settings",
374
+ placement: "top",
375
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
376
+ size: "small",
377
+ sx: {
378
+ marginLeft: 'auto'
379
+ },
380
+ onClick: onDelete,
381
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteOutline.default, {})
382
+ })
383
+ })
384
+ })
385
+ ]
386
+ });
387
+ };
@@ -0,0 +1,131 @@
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, "ValueMappingsEditor", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return ValueMappingsEditor;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _react = require("react");
26
+ const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
27
+ const _ValueMappingEditor = require("./ValueMappingEditor");
28
+ function _interop_require_default(obj) {
29
+ return obj && obj.__esModule ? obj : {
30
+ default: obj
31
+ };
32
+ }
33
+ const ValueMappingsEditor = ({ mappings, onChange })=>{
34
+ const [valueMappings, setValueMappings] = (0, _react.useState)(mappings);
35
+ function handleValueMappingChange(index, mapping) {
36
+ const updatedValueMapings = [
37
+ ...valueMappings
38
+ ];
39
+ updatedValueMapings[index] = mapping;
40
+ setValueMappings(updatedValueMapings);
41
+ onChange(updatedValueMapings);
42
+ }
43
+ function handleAddValueMappingEditor() {
44
+ const updatedValueMapings = [
45
+ ...valueMappings
46
+ ];
47
+ updatedValueMapings.push({
48
+ kind: 'Value',
49
+ spec: {
50
+ result: {
51
+ value: ''
52
+ }
53
+ }
54
+ });
55
+ setValueMappings(updatedValueMapings);
56
+ onChange(updatedValueMapings);
57
+ }
58
+ function handleValueMappingDelete(index) {
59
+ const updatedValueMapings = [
60
+ ...valueMappings
61
+ ];
62
+ updatedValueMapings.splice(index, 1);
63
+ setValueMappings(updatedValueMapings);
64
+ onChange(updatedValueMapings);
65
+ }
66
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
67
+ spacing: 1,
68
+ children: [
69
+ /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Grid2, {
70
+ container: true,
71
+ spacing: 2,
72
+ children: [
73
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
74
+ size: {
75
+ xs: 5
76
+ },
77
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
78
+ variant: "subtitle1",
79
+ children: "Condition"
80
+ })
81
+ }),
82
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
83
+ size: {
84
+ xs: 4
85
+ },
86
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
87
+ variant: "subtitle1",
88
+ children: "Display Text"
89
+ })
90
+ }),
91
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
92
+ size: {
93
+ xs: 1
94
+ },
95
+ textAlign: "center",
96
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
97
+ variant: "subtitle1",
98
+ children: "Color"
99
+ })
100
+ }),
101
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Grid2, {
102
+ size: {
103
+ xs: 1
104
+ }
105
+ })
106
+ ]
107
+ }),
108
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
109
+ gap: 1.5,
110
+ divider: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Divider, {
111
+ flexItem: true,
112
+ orientation: "horizontal"
113
+ }),
114
+ children: valueMappings.map((mapping, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_ValueMappingEditor.ValueMappingEditor, {
115
+ mapping: mapping,
116
+ onChange: (updatedMapping)=>handleValueMappingChange(i, updatedMapping),
117
+ onDelete: ()=>handleValueMappingDelete(i)
118
+ }, i))
119
+ }),
120
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
121
+ variant: "contained",
122
+ startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {}),
123
+ sx: {
124
+ marginTop: 1
125
+ },
126
+ onClick: handleAddValueMappingEditor,
127
+ children: "Add value mappings"
128
+ })
129
+ ]
130
+ });
131
+ };
@@ -0,0 +1,30 @@
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
+ _export_star(require("./ValueMappingsEditor"), exports);
18
+ function _export_star(from, to) {
19
+ Object.keys(from).forEach(function(k) {
20
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
21
+ Object.defineProperty(to, k, {
22
+ enumerable: true,
23
+ get: function() {
24
+ return from[k];
25
+ }
26
+ });
27
+ }
28
+ });
29
+ return from;
30
+ }
@@ -87,7 +87,7 @@ function useTimeZone() {
87
87
  const timeZone = (0, _react.useContext)(TimeZoneContext);
88
88
  return {
89
89
  // fallback to "local" timezone if TimeZoneProvider is not present in the React tree
90
- timeZone: timeZone !== null && timeZone !== void 0 ? timeZone : 'local',
90
+ timeZone: timeZone ?? 'local',
91
91
  formatWithUserTimeZone (date, formatString) {
92
92
  return (0, _utils.formatWithTimeZone)(date, formatString, timeZone);
93
93
  },
@@ -36,7 +36,7 @@ const TextField = /*#__PURE__*/ (0, _react.forwardRef)(function({ debounceMs = 2
36
36
  debounceFn(event.target.value);
37
37
  }
38
38
  const handleDebounceFn = (0, _react.useCallback)((inputValue)=>{
39
- onChange === null || onChange === void 0 ? void 0 : onChange(inputValue);
39
+ onChange?.(inputValue);
40
40
  }, [
41
41
  onChange
42
42
  ]);
package/dist/cjs/index.js CHANGED
@@ -57,6 +57,7 @@ _export_star(require("./TransformsEditor"), exports);
57
57
  _export_star(require("./RefreshIntervalPicker"), exports);
58
58
  _export_star(require("./PieChart"), exports);
59
59
  _export_star(require("./StatusHistoryChart"), exports);
60
+ _export_star(require("./ValueMappingEditor"), exports);
60
61
  function _export_star(from, to) {
61
62
  Object.keys(from).forEach(function(k) {
62
63
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -138,8 +138,7 @@ function batchDispatchNearbySeriesActions(chart, nearbySeriesIndexes, emphasized
138
138
  }
139
139
  }
140
140
  function checkCrosshairPinnedStatus(seriesMapping) {
141
- var _seriesMapping_;
142
- const isCrosshairPinned = ((_seriesMapping_ = seriesMapping[seriesMapping.length - 1]) === null || _seriesMapping_ === void 0 ? void 0 : _seriesMapping_.name) === _model.PINNED_CROSSHAIR_SERIES_NAME;
141
+ const isCrosshairPinned = seriesMapping[seriesMapping.length - 1]?.name === _model.PINNED_CROSSHAIR_SERIES_NAME;
143
142
  return isCrosshairPinned;
144
143
  }
145
144
  function getClosestTimestamp(timeSeriesValues, cursorX) {
@@ -60,7 +60,7 @@ function formatWithTimeZone(date, formatString, timeZone) {
60
60
  * if timeZone is provided, and is not local|browser,
61
61
  * then format using timeZone option (recognize UTC regardless of uppercase/lowercase)
62
62
  * otherwise, format without timeZone option, defaulting to browser timeZone setting
63
- */ const lowerTimeZone = timeZone === null || timeZone === void 0 ? void 0 : timeZone.toLowerCase();
63
+ */ const lowerTimeZone = timeZone?.toLowerCase();
64
64
  if (!timeZone || lowerTimeZone === 'local' || lowerTimeZone === 'browser') {
65
65
  return (0, _datefns.format)(date, formatString);
66
66
  } else {