@perses-dev/components 0.50.0 → 0.50.2

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 (51) hide show
  1. package/dist/DragAndDrop/DragButton.d.ts +2 -2
  2. package/dist/DragAndDrop/DragButton.d.ts.map +1 -1
  3. package/dist/DragAndDrop/DragButton.js +5 -3
  4. package/dist/DragAndDrop/DragButton.js.map +1 -1
  5. package/dist/StatChart/StatChart.d.ts +4 -4
  6. package/dist/StatChart/StatChart.d.ts.map +1 -1
  7. package/dist/StatChart/StatChart.js +6 -10
  8. package/dist/StatChart/StatChart.js.map +1 -1
  9. package/dist/StatChart/utils/formatStatChartValue.d.ts +3 -0
  10. package/dist/StatChart/utils/formatStatChartValue.d.ts.map +1 -0
  11. package/dist/StatChart/utils/formatStatChartValue.js +26 -0
  12. package/dist/StatChart/utils/formatStatChartValue.js.map +1 -0
  13. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts +16 -3
  14. package/dist/StatusHistoryChart/StatusHistoryChart.d.ts.map +1 -1
  15. package/dist/StatusHistoryChart/StatusHistoryChart.js +8 -24
  16. package/dist/StatusHistoryChart/StatusHistoryChart.js.map +1 -1
  17. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts +2 -1
  18. package/dist/StatusHistoryChart/StatusHistoryTooltip.d.ts.map +1 -1
  19. package/dist/StatusHistoryChart/StatusHistoryTooltip.js +3 -3
  20. package/dist/StatusHistoryChart/StatusHistoryTooltip.js.map +1 -1
  21. package/dist/StatusHistoryChart/utils/get-color.d.ts +1 -1
  22. package/dist/StatusHistoryChart/utils/get-color.d.ts.map +1 -1
  23. package/dist/StatusHistoryChart/utils/get-color.js +5 -5
  24. package/dist/StatusHistoryChart/utils/get-color.js.map +1 -1
  25. package/dist/ValueMappingEditor/ValueMappingEditor.d.ts +10 -0
  26. package/dist/ValueMappingEditor/ValueMappingEditor.d.ts.map +1 -0
  27. package/dist/ValueMappingEditor/ValueMappingEditor.js +387 -0
  28. package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -0
  29. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts +8 -0
  30. package/dist/ValueMappingEditor/ValueMappingsEditor.d.ts.map +1 -0
  31. package/dist/ValueMappingEditor/ValueMappingsEditor.js +118 -0
  32. package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -0
  33. package/dist/ValueMappingEditor/index.d.ts +2 -0
  34. package/dist/ValueMappingEditor/index.d.ts.map +1 -0
  35. package/dist/ValueMappingEditor/index.js +15 -0
  36. package/dist/ValueMappingEditor/index.js.map +1 -0
  37. package/dist/cjs/DragAndDrop/DragButton.js +4 -2
  38. package/dist/cjs/StatChart/StatChart.js +8 -12
  39. package/dist/cjs/StatChart/utils/formatStatChartValue.js +34 -0
  40. package/dist/cjs/StatusHistoryChart/StatusHistoryChart.js +10 -26
  41. package/dist/cjs/StatusHistoryChart/StatusHistoryTooltip.js +3 -3
  42. package/dist/cjs/StatusHistoryChart/utils/get-color.js +7 -7
  43. package/dist/cjs/ValueMappingEditor/ValueMappingEditor.js +400 -0
  44. package/dist/cjs/ValueMappingEditor/ValueMappingsEditor.js +131 -0
  45. package/dist/cjs/ValueMappingEditor/index.js +30 -0
  46. package/dist/cjs/index.js +1 -0
  47. package/dist/index.d.ts +1 -0
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +1 -0
  50. package/dist/index.js.map +1 -1
  51. package/package.json +3 -3
@@ -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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { IconButton, MenuItem, Stack, TextField, Tooltip, Typography, Grid2 as Grid } from '@mui/material';
15
+ import DeleteIcon from 'mdi-material-ui/DeleteOutline';
16
+ import PlusIcon from 'mdi-material-ui/Plus';
17
+ import { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';
18
+ const ConditionEditor = ({ mapping, onChange, ...props })=>{
19
+ switch(mapping.kind){
20
+ case 'Value':
21
+ var _mapping_spec;
22
+ var _mapping_spec_value;
23
+ return /*#__PURE__*/ _jsx(Stack, {
24
+ gap: 1,
25
+ direction: "row",
26
+ ...props,
27
+ children: /*#__PURE__*/ _jsx(TextField, {
28
+ label: "Value",
29
+ placeholder: "Exact value",
30
+ value: (_mapping_spec_value = (_mapping_spec = mapping.spec) === null || _mapping_spec === void 0 ? void 0 : _mapping_spec.value) !== null && _mapping_spec_value !== void 0 ? _mapping_spec_value : '',
31
+ onChange: (e)=>onChange({
32
+ ...mapping,
33
+ spec: {
34
+ ...mapping.spec,
35
+ value: e.target.value
36
+ }
37
+ }),
38
+ fullWidth: true
39
+ })
40
+ });
41
+ case 'Range':
42
+ var _mapping_spec1, _mapping_spec2;
43
+ var _mapping_spec_from, _mapping_spec_to;
44
+ return /*#__PURE__*/ _jsxs(Stack, {
45
+ gap: 1,
46
+ direction: "row",
47
+ ...props,
48
+ children: [
49
+ /*#__PURE__*/ _jsx(TextField, {
50
+ label: "From",
51
+ placeholder: "Start of range",
52
+ value: (_mapping_spec_from = (_mapping_spec1 = mapping.spec) === null || _mapping_spec1 === void 0 ? void 0 : _mapping_spec1.from) !== null && _mapping_spec_from !== void 0 ? _mapping_spec_from : '',
53
+ onChange: (e)=>onChange({
54
+ ...mapping,
55
+ spec: {
56
+ ...mapping.spec,
57
+ from: e.target.value === '' ? undefined : +e.target.value
58
+ }
59
+ }),
60
+ fullWidth: true
61
+ }),
62
+ /*#__PURE__*/ _jsx(TextField, {
63
+ label: "To",
64
+ placeholder: "End of range (inclusive)",
65
+ value: (_mapping_spec_to = (_mapping_spec2 = mapping.spec) === null || _mapping_spec2 === void 0 ? void 0 : _mapping_spec2.to) !== null && _mapping_spec_to !== void 0 ? _mapping_spec_to : '',
66
+ onChange: (e)=>onChange({
67
+ ...mapping,
68
+ spec: {
69
+ ...mapping.spec,
70
+ to: e.target.value === '' ? undefined : +e.target.value
71
+ }
72
+ }),
73
+ fullWidth: true
74
+ })
75
+ ]
76
+ });
77
+ case 'Regex':
78
+ var _mapping_spec3;
79
+ var _mapping_spec_pattern;
80
+ return /*#__PURE__*/ _jsx(Stack, {
81
+ gap: 1,
82
+ direction: "row",
83
+ ...props,
84
+ children: /*#__PURE__*/ _jsx(TextField, {
85
+ label: "Regular Expression",
86
+ placeholder: "JavaScript regular expression",
87
+ value: (_mapping_spec_pattern = (_mapping_spec3 = mapping.spec) === null || _mapping_spec3 === void 0 ? void 0 : _mapping_spec3.pattern) !== null && _mapping_spec_pattern !== void 0 ? _mapping_spec_pattern : '',
88
+ onChange: (e)=>onChange({
89
+ ...mapping,
90
+ spec: {
91
+ ...mapping.spec,
92
+ pattern: e.target.value
93
+ }
94
+ }),
95
+ fullWidth: true
96
+ })
97
+ });
98
+ case 'Misc':
99
+ var _mapping_spec4;
100
+ var _mapping_spec_value1;
101
+ return /*#__PURE__*/ _jsx(Stack, {
102
+ gap: 1,
103
+ direction: "row",
104
+ ...props,
105
+ children: /*#__PURE__*/ _jsxs(TextField, {
106
+ select: true,
107
+ label: "Value",
108
+ value: (_mapping_spec_value1 = (_mapping_spec4 = mapping.spec) === null || _mapping_spec4 === void 0 ? void 0 : _mapping_spec4.value) !== null && _mapping_spec_value1 !== void 0 ? _mapping_spec_value1 : '',
109
+ onChange: (e)=>onChange({
110
+ ...mapping,
111
+ spec: {
112
+ value: e.target.value
113
+ }
114
+ }),
115
+ SelectProps: {
116
+ renderValue: (selected)=>{
117
+ switch(selected){
118
+ case 'empty':
119
+ return 'Empty';
120
+ case 'null':
121
+ return 'Null';
122
+ case 'NaN':
123
+ return 'NaN';
124
+ case 'true':
125
+ return 'True';
126
+ case 'false':
127
+ return 'False';
128
+ default:
129
+ return String(selected);
130
+ }
131
+ }
132
+ },
133
+ fullWidth: true,
134
+ children: [
135
+ /*#__PURE__*/ _jsx(MenuItem, {
136
+ value: "empty",
137
+ children: /*#__PURE__*/ _jsxs(Stack, {
138
+ children: [
139
+ /*#__PURE__*/ _jsx(Typography, {
140
+ children: "Empty"
141
+ }),
142
+ /*#__PURE__*/ _jsx(Typography, {
143
+ variant: "caption",
144
+ children: "Matches empty string"
145
+ })
146
+ ]
147
+ })
148
+ }),
149
+ /*#__PURE__*/ _jsx(MenuItem, {
150
+ value: "null",
151
+ children: /*#__PURE__*/ _jsxs(Stack, {
152
+ children: [
153
+ /*#__PURE__*/ _jsx(Typography, {
154
+ children: "Null"
155
+ }),
156
+ /*#__PURE__*/ _jsx(Typography, {
157
+ variant: "caption",
158
+ children: "Matches null or undefined"
159
+ })
160
+ ]
161
+ })
162
+ }),
163
+ /*#__PURE__*/ _jsx(MenuItem, {
164
+ value: "NaN",
165
+ children: /*#__PURE__*/ _jsxs(Stack, {
166
+ children: [
167
+ /*#__PURE__*/ _jsx(Typography, {
168
+ children: "NaN"
169
+ }),
170
+ /*#__PURE__*/ _jsx(Typography, {
171
+ variant: "caption",
172
+ children: "Matches Not a Number value"
173
+ })
174
+ ]
175
+ })
176
+ }),
177
+ /*#__PURE__*/ _jsx(MenuItem, {
178
+ value: "true",
179
+ children: /*#__PURE__*/ _jsxs(Stack, {
180
+ children: [
181
+ /*#__PURE__*/ _jsx(Typography, {
182
+ children: "True"
183
+ }),
184
+ /*#__PURE__*/ _jsx(Typography, {
185
+ variant: "caption",
186
+ children: "Matches true boolean"
187
+ })
188
+ ]
189
+ })
190
+ }),
191
+ /*#__PURE__*/ _jsx(MenuItem, {
192
+ value: "false",
193
+ children: /*#__PURE__*/ _jsxs(Stack, {
194
+ children: [
195
+ /*#__PURE__*/ _jsx(Typography, {
196
+ children: "False"
197
+ }),
198
+ /*#__PURE__*/ _jsx(Typography, {
199
+ variant: "caption",
200
+ children: "Matches false boolean"
201
+ })
202
+ ]
203
+ })
204
+ })
205
+ ]
206
+ })
207
+ });
208
+ default:
209
+ return null;
210
+ }
211
+ };
212
+ export const ValueMappingEditor = ({ mapping, onChange, onDelete, ...props })=>{
213
+ var _mapping_spec_result, _mapping_spec, _mapping_spec_result1, _mapping_spec1;
214
+ const handleColorChange = (color)=>{
215
+ onChange({
216
+ ...mapping,
217
+ spec: {
218
+ ...mapping.spec,
219
+ result: {
220
+ ...mapping.spec.result,
221
+ color
222
+ }
223
+ }
224
+ });
225
+ };
226
+ var _mapping_spec_result_value, _mapping_spec_result_color;
227
+ return /*#__PURE__*/ _jsxs(Grid, {
228
+ container: true,
229
+ spacing: 2,
230
+ ...props,
231
+ children: [
232
+ /*#__PURE__*/ _jsx(Grid, {
233
+ size: {
234
+ xs: 5
235
+ },
236
+ children: /*#__PURE__*/ _jsxs(Stack, {
237
+ direction: "row",
238
+ gap: 1,
239
+ width: "100%",
240
+ children: [
241
+ /*#__PURE__*/ _jsxs(TextField, {
242
+ select: true,
243
+ label: "Type",
244
+ value: mapping.kind,
245
+ onChange: (e)=>onChange({
246
+ ...mapping,
247
+ kind: e.target.value
248
+ }),
249
+ required: true,
250
+ sx: {
251
+ width: '120px'
252
+ },
253
+ children: [
254
+ /*#__PURE__*/ _jsx(MenuItem, {
255
+ value: "Value",
256
+ children: /*#__PURE__*/ _jsxs(Stack, {
257
+ children: [
258
+ /*#__PURE__*/ _jsx(Typography, {
259
+ children: "Value"
260
+ }),
261
+ mapping.kind !== 'Value' && /*#__PURE__*/ _jsx(Typography, {
262
+ variant: "caption",
263
+ children: "Matches an exact text value"
264
+ })
265
+ ]
266
+ })
267
+ }),
268
+ /*#__PURE__*/ _jsx(MenuItem, {
269
+ value: "Range",
270
+ children: /*#__PURE__*/ _jsxs(Stack, {
271
+ children: [
272
+ /*#__PURE__*/ _jsx(Typography, {
273
+ children: "Range"
274
+ }),
275
+ mapping.kind !== 'Range' && /*#__PURE__*/ _jsx(Typography, {
276
+ variant: "caption",
277
+ children: "Matches against a numerical range"
278
+ })
279
+ ]
280
+ })
281
+ }),
282
+ /*#__PURE__*/ _jsx(MenuItem, {
283
+ value: "Regex",
284
+ children: /*#__PURE__*/ _jsxs(Stack, {
285
+ children: [
286
+ /*#__PURE__*/ _jsx(Typography, {
287
+ children: "Regex"
288
+ }),
289
+ mapping.kind !== 'Regex' && /*#__PURE__*/ _jsx(Typography, {
290
+ variant: "caption",
291
+ children: "Matches against a regular expression"
292
+ })
293
+ ]
294
+ })
295
+ }),
296
+ /*#__PURE__*/ _jsx(MenuItem, {
297
+ value: "Misc",
298
+ children: /*#__PURE__*/ _jsxs(Stack, {
299
+ children: [
300
+ /*#__PURE__*/ _jsx(Typography, {
301
+ children: "Misc"
302
+ }),
303
+ mapping.kind !== 'Misc' && /*#__PURE__*/ _jsx(Typography, {
304
+ variant: "caption",
305
+ children: "Matches against empty, null and NaN values"
306
+ })
307
+ ]
308
+ })
309
+ })
310
+ ]
311
+ }),
312
+ /*#__PURE__*/ _jsx(ConditionEditor, {
313
+ width: "100%",
314
+ mapping: mapping,
315
+ onChange: (updatedMapping)=>onChange({
316
+ ...mapping,
317
+ ...updatedMapping
318
+ })
319
+ })
320
+ ]
321
+ })
322
+ }),
323
+ /*#__PURE__*/ _jsx(Grid, {
324
+ size: {
325
+ xs: 4
326
+ },
327
+ children: /*#__PURE__*/ _jsx(TextField, {
328
+ label: "Display text",
329
+ value: (_mapping_spec_result_value = (_mapping_spec = mapping.spec) === null || _mapping_spec === void 0 ? void 0 : (_mapping_spec_result = _mapping_spec.result) === null || _mapping_spec_result === void 0 ? void 0 : _mapping_spec_result.value) !== null && _mapping_spec_result_value !== void 0 ? _mapping_spec_result_value : '',
330
+ onChange: (e)=>{
331
+ var _mapping_spec;
332
+ return onChange({
333
+ ...mapping,
334
+ spec: {
335
+ ...mapping.spec,
336
+ result: {
337
+ ...(_mapping_spec = mapping.spec) === null || _mapping_spec === void 0 ? void 0 : _mapping_spec.result,
338
+ value: e.target.value
339
+ }
340
+ }
341
+ });
342
+ },
343
+ fullWidth: true
344
+ })
345
+ }),
346
+ /*#__PURE__*/ _jsx(Grid, {
347
+ size: {
348
+ xs: 1
349
+ },
350
+ children: /*#__PURE__*/ _jsx(Stack, {
351
+ direction: "row",
352
+ justifyContent: "center",
353
+ gap: 1,
354
+ children: ((_mapping_spec1 = mapping.spec) === null || _mapping_spec1 === void 0 ? void 0 : (_mapping_spec_result1 = _mapping_spec1.result) === null || _mapping_spec_result1 === void 0 ? void 0 : _mapping_spec_result1.color) ? /*#__PURE__*/ _jsx(OptionsColorPicker, {
355
+ label: "Color",
356
+ color: (_mapping_spec_result_color = mapping.spec.result.color) !== null && _mapping_spec_result_color !== void 0 ? _mapping_spec_result_color : '#000',
357
+ onColorChange: handleColorChange,
358
+ onClear: ()=>handleColorChange(undefined)
359
+ }) : /*#__PURE__*/ _jsx(IconButton, {
360
+ onClick: ()=>handleColorChange('#000'),
361
+ children: /*#__PURE__*/ _jsx(PlusIcon, {})
362
+ })
363
+ })
364
+ }),
365
+ /*#__PURE__*/ _jsx(Grid, {
366
+ size: {
367
+ xs: 1
368
+ },
369
+ textAlign: "end",
370
+ children: /*#__PURE__*/ _jsx(Tooltip, {
371
+ title: "Remove mapping settings",
372
+ placement: "top",
373
+ children: /*#__PURE__*/ _jsx(IconButton, {
374
+ size: "small",
375
+ sx: {
376
+ marginLeft: 'auto'
377
+ },
378
+ onClick: onDelete,
379
+ children: /*#__PURE__*/ _jsx(DeleteIcon, {})
380
+ })
381
+ })
382
+ })
383
+ ]
384
+ });
385
+ };
386
+
387
+ //# sourceMappingURL=ValueMappingEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ValueMappingEditor/ValueMappingEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport {\n Grid2Props as GridProps,\n IconButton,\n MenuItem,\n Stack,\n StackProps,\n TextField,\n Tooltip,\n Typography,\n Grid2 as Grid,\n} from '@mui/material';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport PlusIcon from 'mdi-material-ui/Plus';\nimport { ValueMapping } from '@perses-dev/core';\nimport { FC } from 'react';\nimport { OptionsColorPicker } from '../ColorPicker/OptionsColorPicker';\n\ninterface ValueMappingConditionEditorProps extends Omit<StackProps, 'onChange'> {\n mapping: ValueMapping;\n onChange: (condition: ValueMapping) => void;\n}\n\nconst ConditionEditor: FC<ValueMappingConditionEditorProps> = ({ mapping, onChange, ...props }) => {\n switch (mapping.kind) {\n case 'Value':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"Value\"\n placeholder=\"Exact value\"\n value={mapping.spec?.value ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, value: e.target.value },\n })\n }\n fullWidth\n />\n </Stack>\n );\n case 'Range':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"From\"\n placeholder=\"Start of range\"\n value={mapping.spec?.from ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, from: e.target.value === '' ? undefined : +e.target.value },\n })\n }\n fullWidth\n />\n <TextField\n label=\"To\"\n placeholder=\"End of range (inclusive)\"\n value={mapping.spec?.to ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: { ...mapping.spec, to: e.target.value === '' ? undefined : +e.target.value },\n })\n }\n fullWidth\n />\n </Stack>\n );\n case 'Regex':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n label=\"Regular Expression\"\n placeholder=\"JavaScript regular expression\"\n value={mapping.spec?.pattern ?? ''}\n onChange={(e) => onChange({ ...mapping, spec: { ...mapping.spec, pattern: e.target.value } })}\n fullWidth\n />\n </Stack>\n );\n case 'Misc':\n return (\n <Stack gap={1} direction=\"row\" {...props}>\n <TextField\n select\n label=\"Value\"\n value={mapping.spec?.value ?? ''}\n onChange={(e) => onChange({ ...mapping, spec: { value: e.target.value } } as ValueMapping)}\n SelectProps={{\n renderValue: (selected) => {\n switch (selected) {\n case 'empty':\n return 'Empty';\n case 'null':\n return 'Null';\n case 'NaN':\n return 'NaN';\n case 'true':\n return 'True';\n case 'false':\n return 'False';\n default:\n return String(selected);\n }\n },\n }}\n fullWidth\n >\n <MenuItem value=\"empty\">\n <Stack>\n <Typography>Empty</Typography>\n <Typography variant=\"caption\">Matches empty string</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"null\">\n <Stack>\n <Typography>Null</Typography>\n <Typography variant=\"caption\">Matches null or undefined</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"NaN\">\n <Stack>\n <Typography>NaN</Typography>\n <Typography variant=\"caption\">Matches Not a Number value</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"true\">\n <Stack>\n <Typography>True</Typography>\n <Typography variant=\"caption\">Matches true boolean</Typography>\n </Stack>\n </MenuItem>\n <MenuItem value=\"false\">\n <Stack>\n <Typography>False</Typography>\n <Typography variant=\"caption\">Matches false boolean</Typography>\n </Stack>\n </MenuItem>\n </TextField>\n </Stack>\n );\n default:\n return null;\n }\n};\nexport interface ValueMappingEditorProps extends Omit<GridProps, 'onChange'> {\n mapping: ValueMapping;\n onChange: (mapping: ValueMapping) => void;\n onDelete: () => void;\n}\n\nexport const ValueMappingEditor: FC<ValueMappingEditorProps> = ({ mapping, onChange, onDelete, ...props }) => {\n const handleColorChange = (color?: string): void => {\n onChange({\n ...mapping,\n spec: {\n ...mapping.spec,\n result: {\n ...mapping.spec.result,\n color,\n },\n },\n } as ValueMapping);\n };\n return (\n <Grid container spacing={2} {...props}>\n <Grid size={{ xs: 5 }}>\n <Stack direction=\"row\" gap={1} width=\"100%\">\n <TextField\n select\n label=\"Type\"\n value={mapping.kind}\n onChange={(e) => onChange({ ...mapping, kind: e.target.value } as ValueMapping)}\n required\n sx={{ width: '120px' }}\n >\n <MenuItem value=\"Value\">\n <Stack>\n <Typography>Value</Typography>\n {mapping.kind !== 'Value' && <Typography variant=\"caption\">Matches an exact text value</Typography>}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Range\">\n <Stack>\n <Typography>Range</Typography>\n {mapping.kind !== 'Range' && (\n <Typography variant=\"caption\">Matches against a numerical range</Typography>\n )}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Regex\">\n <Stack>\n <Typography>Regex</Typography>\n {mapping.kind !== 'Regex' && (\n <Typography variant=\"caption\">Matches against a regular expression</Typography>\n )}\n </Stack>\n </MenuItem>\n <MenuItem value=\"Misc\">\n <Stack>\n <Typography>Misc</Typography>\n {mapping.kind !== 'Misc' && (\n <Typography variant=\"caption\">Matches against empty, null and NaN values</Typography>\n )}\n </Stack>\n </MenuItem>\n </TextField>\n <ConditionEditor\n width=\"100%\"\n mapping={mapping}\n onChange={(updatedMapping) => onChange({ ...mapping, ...updatedMapping })}\n />\n </Stack>\n </Grid>\n <Grid size={{ xs: 4 }}>\n <TextField\n label=\"Display text\"\n value={mapping.spec?.result?.value ?? ''}\n onChange={(e) =>\n onChange({\n ...mapping,\n spec: {\n ...mapping.spec,\n result: {\n ...mapping.spec?.result,\n value: e.target.value,\n },\n },\n } as ValueMapping)\n }\n fullWidth\n />\n </Grid>\n <Grid size={{ xs: 1 }}>\n <Stack direction=\"row\" justifyContent=\"center\" gap={1}>\n {mapping.spec?.result?.color ? (\n <OptionsColorPicker\n label=\"Color\"\n color={mapping.spec.result.color ?? '#000'}\n onColorChange={handleColorChange}\n onClear={() => handleColorChange(undefined)}\n />\n ) : (\n <IconButton onClick={() => handleColorChange('#000')}>\n <PlusIcon />\n </IconButton>\n )}\n </Stack>\n </Grid>\n <Grid size={{ xs: 1 }} textAlign=\"end\">\n <Tooltip title=\"Remove mapping settings\" placement=\"top\">\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n </Grid>\n </Grid>\n );\n};\n"],"names":["IconButton","MenuItem","Stack","TextField","Tooltip","Typography","Grid2","Grid","DeleteIcon","PlusIcon","OptionsColorPicker","ConditionEditor","mapping","onChange","props","kind","gap","direction","label","placeholder","value","spec","e","target","fullWidth","from","undefined","to","pattern","select","SelectProps","renderValue","selected","String","variant","ValueMappingEditor","onDelete","handleColorChange","color","result","container","spacing","size","xs","width","required","sx","updatedMapping","justifyContent","onColorChange","onClear","onClick","textAlign","title","placement","marginLeft"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAEEA,UAAU,EACVC,QAAQ,EACRC,KAAK,EAELC,SAAS,EACTC,OAAO,EACPC,UAAU,EACVC,SAASC,IAAI,QACR,gBAAgB;AACvB,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,cAAc,uBAAuB;AAG5C,SAASC,kBAAkB,QAAQ,oCAAoC;AAOvE,MAAMC,kBAAwD,CAAC,EAAEC,OAAO,EAAEC,QAAQ,EAAE,GAAGC,OAAO;IAC5F,OAAQF,QAAQG,IAAI;QAClB,KAAK;gBAMUH;gBAAAA;YALb,qBACE,KAACV;gBAAMc,KAAK;gBAAGC,WAAU;gBAAO,GAAGH,KAAK;0BACtC,cAAA,KAACX;oBACCe,OAAM;oBACNC,aAAY;oBACZC,OAAOR,CAAAA,uBA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,CAAAA,6BAAAA,QAAQS,IAAI,CAACkB,MAAM,CAACD,KAAK,cAAzB1B,wCAAAA,6BAA6B;wBACpCqC,eAAeZ;wBACfa,SAAS,IAAMb,kBAAkBX;uCAGnC,KAAC1B;wBAAWmD,SAAS,IAAMd,kBAAkB;kCAC3C,cAAA,KAAC5B;;;;0BAKT,KAACF;gBAAKmC,MAAM;oBAAEC,IAAI;gBAAE;gBAAGS,WAAU;0BAC/B,cAAA,KAAChD;oBAAQiD,OAAM;oBAA0BC,WAAU;8BACjD,cAAA,KAACtD;wBAAW0C,MAAK;wBAAQI,IAAI;4BAAES,YAAY;wBAAO;wBAAGJ,SAASf;kCAC5D,cAAA,KAAC5B;;;;;;AAMb,EAAE"}
@@ -0,0 +1,8 @@
1
+ import { FC } from 'react';
2
+ import { ValueMapping } from '@perses-dev/core';
3
+ export interface ValueMappingsEditorProps {
4
+ mappings: ValueMapping[];
5
+ onChange: (valueMappings: ValueMapping[]) => void;
6
+ }
7
+ export declare const ValueMappingsEditor: FC<ValueMappingsEditorProps>;
8
+ //# sourceMappingURL=ValueMappingsEditor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ValueMappingsEditor.d.ts","sourceRoot":"","sources":["../../src/ValueMappingEditor/ValueMappingsEditor.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAE,EAAE,EAAY,MAAM,OAAO,CAAC;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,YAAY,EAAE,CAAC;IACzB,QAAQ,EAAE,CAAC,aAAa,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;CACnD;AAED,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,wBAAwB,CAsD5D,CAAC"}
@@ -0,0 +1,118 @@
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
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Button, Divider, Stack, Typography, Grid2 as Grid } from '@mui/material';
15
+ import { useState } from 'react';
16
+ import AddIcon from 'mdi-material-ui/Plus';
17
+ import { ValueMappingEditor } from './ValueMappingEditor';
18
+ export const ValueMappingsEditor = ({ mappings, onChange })=>{
19
+ const [valueMappings, setValueMappings] = useState(mappings);
20
+ function handleValueMappingChange(index, mapping) {
21
+ const updatedValueMapings = [
22
+ ...valueMappings
23
+ ];
24
+ updatedValueMapings[index] = mapping;
25
+ setValueMappings(updatedValueMapings);
26
+ onChange(updatedValueMapings);
27
+ }
28
+ function handleAddValueMappingEditor() {
29
+ const updatedValueMapings = [
30
+ ...valueMappings
31
+ ];
32
+ updatedValueMapings.push({
33
+ kind: 'Value',
34
+ spec: {
35
+ result: {
36
+ value: ''
37
+ }
38
+ }
39
+ });
40
+ setValueMappings(updatedValueMapings);
41
+ onChange(updatedValueMapings);
42
+ }
43
+ function handleValueMappingDelete(index) {
44
+ const updatedValueMapings = [
45
+ ...valueMappings
46
+ ];
47
+ updatedValueMapings.splice(index, 1);
48
+ setValueMappings(updatedValueMapings);
49
+ onChange(updatedValueMapings);
50
+ }
51
+ return /*#__PURE__*/ _jsxs(Stack, {
52
+ spacing: 1,
53
+ children: [
54
+ /*#__PURE__*/ _jsxs(Grid, {
55
+ container: true,
56
+ spacing: 2,
57
+ children: [
58
+ /*#__PURE__*/ _jsx(Grid, {
59
+ size: {
60
+ xs: 5
61
+ },
62
+ children: /*#__PURE__*/ _jsx(Typography, {
63
+ variant: "subtitle1",
64
+ children: "Condition"
65
+ })
66
+ }),
67
+ /*#__PURE__*/ _jsx(Grid, {
68
+ size: {
69
+ xs: 4
70
+ },
71
+ children: /*#__PURE__*/ _jsx(Typography, {
72
+ variant: "subtitle1",
73
+ children: "Display Text"
74
+ })
75
+ }),
76
+ /*#__PURE__*/ _jsx(Grid, {
77
+ size: {
78
+ xs: 1
79
+ },
80
+ textAlign: "center",
81
+ children: /*#__PURE__*/ _jsx(Typography, {
82
+ variant: "subtitle1",
83
+ children: "Color"
84
+ })
85
+ }),
86
+ /*#__PURE__*/ _jsx(Grid, {
87
+ size: {
88
+ xs: 1
89
+ }
90
+ })
91
+ ]
92
+ }),
93
+ /*#__PURE__*/ _jsx(Stack, {
94
+ gap: 1.5,
95
+ divider: /*#__PURE__*/ _jsx(Divider, {
96
+ flexItem: true,
97
+ orientation: "horizontal"
98
+ }),
99
+ children: valueMappings.map((mapping, i)=>/*#__PURE__*/ _jsx(ValueMappingEditor, {
100
+ mapping: mapping,
101
+ onChange: (updatedMapping)=>handleValueMappingChange(i, updatedMapping),
102
+ onDelete: ()=>handleValueMappingDelete(i)
103
+ }, i))
104
+ }),
105
+ /*#__PURE__*/ _jsx(Button, {
106
+ variant: "contained",
107
+ startIcon: /*#__PURE__*/ _jsx(AddIcon, {}),
108
+ sx: {
109
+ marginTop: 1
110
+ },
111
+ onClick: handleAddValueMappingEditor,
112
+ children: "Add value mappings"
113
+ })
114
+ ]
115
+ });
116
+ };
117
+
118
+ //# sourceMappingURL=ValueMappingsEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ValueMappingEditor/ValueMappingsEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Button, Divider, Stack, Typography, Grid2 as Grid } from '@mui/material';\n\nimport { FC, useState } from 'react';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { ValueMapping } from '@perses-dev/core';\nimport { ValueMappingEditor } from './ValueMappingEditor';\n\nexport interface ValueMappingsEditorProps {\n mappings: ValueMapping[];\n onChange: (valueMappings: ValueMapping[]) => void;\n}\n\nexport const ValueMappingsEditor: FC<ValueMappingsEditorProps> = ({ mappings, onChange }) => {\n const [valueMappings, setValueMappings] = useState<ValueMapping[]>(mappings);\n\n function handleValueMappingChange(index: number, mapping: ValueMapping): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings[index] = mapping;\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n function handleAddValueMappingEditor(): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings.push({ kind: 'Value', spec: { result: { value: '' } } } as ValueMapping);\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n function handleValueMappingDelete(index: number): void {\n const updatedValueMapings = [...valueMappings];\n updatedValueMapings.splice(index, 1);\n setValueMappings(updatedValueMapings);\n onChange(updatedValueMapings);\n }\n\n return (\n <Stack spacing={1}>\n <Grid container spacing={2}>\n <Grid size={{ xs: 5 }}>\n <Typography variant=\"subtitle1\">Condition</Typography>\n </Grid>\n <Grid size={{ xs: 4 }}>\n <Typography variant=\"subtitle1\">Display Text</Typography>\n </Grid>\n <Grid size={{ xs: 1 }} textAlign=\"center\">\n <Typography variant=\"subtitle1\">Color</Typography>\n </Grid>\n <Grid size={{ xs: 1 }}></Grid>\n </Grid>\n <Stack gap={1.5} divider={<Divider flexItem orientation=\"horizontal\" />}>\n {valueMappings.map((mapping, i) => (\n <ValueMappingEditor\n key={i}\n mapping={mapping}\n onChange={(updatedMapping: ValueMapping) => handleValueMappingChange(i, updatedMapping)}\n onDelete={() => handleValueMappingDelete(i)}\n />\n ))}\n </Stack>\n\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleAddValueMappingEditor}>\n Add value mappings\n </Button>\n </Stack>\n );\n};\n"],"names":["Button","Divider","Stack","Typography","Grid2","Grid","useState","AddIcon","ValueMappingEditor","ValueMappingsEditor","mappings","onChange","valueMappings","setValueMappings","handleValueMappingChange","index","mapping","updatedValueMapings","handleAddValueMappingEditor","push","kind","spec","result","value","handleValueMappingDelete","splice","spacing","container","size","xs","variant","textAlign","gap","divider","flexItem","orientation","map","i","updatedMapping","onDelete","startIcon","sx","marginTop","onClick"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,EAAEC,SAASC,IAAI,QAAQ,gBAAgB;AAElF,SAAaC,QAAQ,QAAQ,QAAQ;AACrC,OAAOC,aAAa,uBAAuB;AAE3C,SAASC,kBAAkB,QAAQ,uBAAuB;AAO1D,OAAO,MAAMC,sBAAoD,CAAC,EAAEC,QAAQ,EAAEC,QAAQ,EAAE;IACtF,MAAM,CAACC,eAAeC,iBAAiB,GAAGP,SAAyBI;IAEnE,SAASI,yBAAyBC,KAAa,EAAEC,OAAqB;QACpE,MAAMC,sBAAsB;eAAIL;SAAc;QAC9CK,mBAAmB,CAACF,MAAM,GAAGC;QAC7BH,iBAAiBI;QACjBN,SAASM;IACX;IAEA,SAASC;QACP,MAAMD,sBAAsB;eAAIL;SAAc;QAC9CK,oBAAoBE,IAAI,CAAC;YAAEC,MAAM;YAASC,MAAM;gBAAEC,QAAQ;oBAAEC,OAAO;gBAAG;YAAE;QAAE;QAC1EV,iBAAiBI;QACjBN,SAASM;IACX;IAEA,SAASO,yBAAyBT,KAAa;QAC7C,MAAME,sBAAsB;eAAIL;SAAc;QAC9CK,oBAAoBQ,MAAM,CAACV,OAAO;QAClCF,iBAAiBI;QACjBN,SAASM;IACX;IAEA,qBACE,MAACf;QAAMwB,SAAS;;0BACd,MAACrB;gBAAKsB,SAAS;gBAACD,SAAS;;kCACvB,KAACrB;wBAAKuB,MAAM;4BAAEC,IAAI;wBAAE;kCAClB,cAAA,KAAC1B;4BAAW2B,SAAQ;sCAAY;;;kCAElC,KAACzB;wBAAKuB,MAAM;4BAAEC,IAAI;wBAAE;kCAClB,cAAA,KAAC1B;4BAAW2B,SAAQ;sCAAY;;;kCAElC,KAACzB;wBAAKuB,MAAM;4BAAEC,IAAI;wBAAE;wBAAGE,WAAU;kCAC/B,cAAA,KAAC5B;4BAAW2B,SAAQ;sCAAY;;;kCAElC,KAACzB;wBAAKuB,MAAM;4BAAEC,IAAI;wBAAE;;;;0BAEtB,KAAC3B;gBAAM8B,KAAK;gBAAKC,uBAAS,KAAChC;oBAAQiC,QAAQ;oBAACC,aAAY;;0BACrDvB,cAAcwB,GAAG,CAAC,CAACpB,SAASqB,kBAC3B,KAAC7B;wBAECQ,SAASA;wBACTL,UAAU,CAAC2B,iBAAiCxB,yBAAyBuB,GAAGC;wBACxEC,UAAU,IAAMf,yBAAyBa;uBAHpCA;;0BAQX,KAACrC;gBAAO8B,SAAQ;gBAAYU,yBAAW,KAACjC;gBAAYkC,IAAI;oBAAEC,WAAW;gBAAE;gBAAGC,SAASzB;0BAA6B;;;;AAKtH,EAAE"}
@@ -0,0 +1,2 @@
1
+ export * from './ValueMappingsEditor';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ValueMappingEditor/index.ts"],"names":[],"mappings":"AAaA,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,15 @@
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
+ export * from './ValueMappingsEditor';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ValueMappingEditor/index.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './ValueMappingsEditor';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,wBAAwB"}
@@ -64,7 +64,7 @@ function handleMoveDown(element, elements) {
64
64
  newElements.splice(index + 1, 0, element);
65
65
  return newElements;
66
66
  }
67
- function DragButton({ onMoveUp, onMoveDown, onMoveLeft, onMoveRight, menuSx }) {
67
+ const DragButton = /*#__PURE__*/ (0, _react.forwardRef)(function DragButton({ onMoveUp, onMoveDown, onMoveLeft, onMoveRight, menuSx, ...otherProps }, ref) {
68
68
  const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
69
69
  const open = Boolean(anchorEl);
70
70
  function handleClick(event) {
@@ -77,6 +77,8 @@ function DragButton({ onMoveUp, onMoveDown, onMoveLeft, onMoveRight, menuSx }) {
77
77
  return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
78
78
  children: [
79
79
  /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
80
+ ...otherProps,
81
+ ref: ref,
80
82
  "aria-label": "move",
81
83
  "aria-haspopup": true,
82
84
  "aria-expanded": open,
@@ -118,4 +120,4 @@ function DragButton({ onMoveUp, onMoveDown, onMoveLeft, onMoveRight, menuSx }) {
118
120
  })
119
121
  ]
120
122
  });
121
- }
123
+ });