@perses-dev/timeseries-chart-plugin 0.13.0 → 0.14.0-beta.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 (172) hide show
  1. package/__mf/js/TimeSeriesChart.b9caac04.js +7 -0
  2. package/__mf/js/async/121.fde1320e.js +2 -0
  3. package/__mf/js/async/{527.f97d1b86.js → 182.9e1e293f.js} +9 -9
  4. package/__mf/js/async/192.66c6659d.js +1 -0
  5. package/__mf/js/async/2.166bda4f.js +1 -0
  6. package/__mf/js/async/235.76fd7af2.js +1 -0
  7. package/__mf/js/async/274.e4ed32f7.js +2 -0
  8. package/__mf/js/async/319.8e262f9c.js +1 -0
  9. package/__mf/js/async/356.52455d93.js +1 -0
  10. package/__mf/js/async/384.f40367cc.js +1 -0
  11. package/__mf/js/async/392.8cb3dcaa.js +2 -0
  12. package/__mf/js/async/463.f5dc7759.js +7 -0
  13. package/__mf/js/async/{694.0fb9ee5a.js.LICENSE.txt → 463.f5dc7759.js.LICENSE.txt} +41 -1
  14. package/__mf/js/async/465.add3260a.js +1 -0
  15. package/__mf/js/async/470.beedcbcc.js +2 -0
  16. package/__mf/js/async/522.806db24f.js +22 -0
  17. package/__mf/js/async/525.8b92c616.js +37 -0
  18. package/__mf/js/async/587.828c454a.js +1 -0
  19. package/__mf/js/async/597.0c5bd6dd.js +2 -0
  20. package/__mf/js/async/612.b2f31132.js +3 -0
  21. package/__mf/js/async/616.804d525d.js +1 -0
  22. package/__mf/js/async/663.892b9ad5.js +1 -0
  23. package/__mf/js/async/700.25c7e5dd.js +1 -0
  24. package/__mf/js/async/724.f74ffa12.js +1 -0
  25. package/__mf/js/async/730.058dea58.js +2 -0
  26. package/__mf/js/async/865.cb917066.js +2 -0
  27. package/__mf/js/async/941.3bb54150.js +2 -0
  28. package/__mf/js/async/955.52ca0671.js +1 -0
  29. package/__mf/js/async/968.2dd830b3.js +1 -0
  30. package/__mf/js/async/__federation_expose_TimeSeriesChart.4ddb01e0.js +1 -0
  31. package/__mf/js/async/lib-router.ecb51f08.js +2 -0
  32. package/__mf/js/main.f55169be.js +7 -0
  33. package/lib/GeneralSettingsEditor.d.ts +2 -2
  34. package/lib/GeneralSettingsEditor.d.ts.map +1 -1
  35. package/lib/GeneralSettingsEditor.js +7 -7
  36. package/lib/GeneralSettingsEditor.js.map +1 -1
  37. package/lib/QuerySettingsEditor.d.ts +2 -2
  38. package/lib/QuerySettingsEditor.d.ts.map +1 -1
  39. package/lib/QuerySettingsEditor.js +11 -11
  40. package/lib/QuerySettingsEditor.js.map +1 -1
  41. package/lib/TimeSeriesChart.d.ts +3 -3
  42. package/lib/TimeSeriesChart.d.ts.map +1 -1
  43. package/lib/TimeSeriesChart.js +6 -5
  44. package/lib/TimeSeriesChart.js.map +1 -1
  45. package/lib/TimeSeriesChartBase.d.ts +4 -4
  46. package/lib/TimeSeriesChartBase.d.ts.map +1 -1
  47. package/lib/TimeSeriesChartBase.js +12 -12
  48. package/lib/TimeSeriesChartBase.js.map +1 -1
  49. package/lib/TimeSeriesChartPanel.d.ts +4 -4
  50. package/lib/TimeSeriesChartPanel.d.ts.map +1 -1
  51. package/lib/TimeSeriesChartPanel.js +12 -12
  52. package/lib/TimeSeriesChartPanel.js.map +1 -1
  53. package/lib/TimeSeriesExportAction.d.ts +1 -1
  54. package/lib/TimeSeriesExportAction.d.ts.map +1 -1
  55. package/lib/TimeSeriesExportAction.js +5 -5
  56. package/lib/TimeSeriesExportAction.js.map +1 -1
  57. package/lib/VisualOptionsEditor.d.ts +2 -2
  58. package/lib/VisualOptionsEditor.d.ts.map +1 -1
  59. package/lib/VisualOptionsEditor.js +4 -4
  60. package/lib/VisualOptionsEditor.js.map +1 -1
  61. package/lib/YAxisOptionsEditor.d.ts +2 -2
  62. package/lib/YAxisOptionsEditor.d.ts.map +1 -1
  63. package/lib/YAxisOptionsEditor.js +3 -3
  64. package/lib/YAxisOptionsEditor.js.map +1 -1
  65. package/lib/annotations/AnnotationTooltip.d.ts +2 -2
  66. package/lib/annotations/AnnotationTooltip.d.ts.map +1 -1
  67. package/lib/annotations/AnnotationTooltip.js +6 -6
  68. package/lib/annotations/AnnotationTooltip.js.map +1 -1
  69. package/lib/bootstrap.js +2 -2
  70. package/lib/getPluginModule.d.ts +1 -1
  71. package/lib/getPluginModule.d.ts.map +1 -1
  72. package/lib/getPluginModule.js +3 -1
  73. package/lib/getPluginModule.js.map +1 -1
  74. package/lib/index-federation.js +1 -1
  75. package/lib/index.js +9 -9
  76. package/lib/index.js.map +1 -1
  77. package/lib/setup-tests.d.ts +1 -1
  78. package/lib/setup-tests.d.ts.map +1 -1
  79. package/lib/setup-tests.js +2 -2
  80. package/lib/setup-tests.js.map +1 -1
  81. package/lib/test/mock-query-results.d.ts +1 -1
  82. package/lib/test/mock-query-results.d.ts.map +1 -1
  83. package/lib/test/mock-query-results.js.map +1 -1
  84. package/lib/time-series-chart-model.d.ts +3 -3
  85. package/lib/time-series-chart-model.d.ts.map +1 -1
  86. package/lib/time-series-chart-model.js.map +1 -1
  87. package/lib/utils/annotation.d.ts +2 -2
  88. package/lib/utils/annotation.d.ts.map +1 -1
  89. package/lib/utils/annotation.js.map +1 -1
  90. package/lib/utils/data-transform.d.ts +5 -5
  91. package/lib/utils/data-transform.d.ts.map +1 -1
  92. package/lib/utils/data-transform.js +3 -3
  93. package/lib/utils/data-transform.js.map +1 -1
  94. package/lib/utils/palette-gen.d.ts +1 -1
  95. package/lib/utils/palette-gen.d.ts.map +1 -1
  96. package/lib/utils/palette-gen.js +1 -1
  97. package/lib/utils/palette-gen.js.map +1 -1
  98. package/lib/utils/palette.js +1 -1
  99. package/lib/utils/palette.js.map +1 -1
  100. package/lib/utils/timezone-formatter.js +1 -1
  101. package/mf-manifest.json +37 -81
  102. package/mf-stats.json +39 -91
  103. package/package.json +11 -11
  104. package/__mf/js/TimeSeriesChart.42841bce.js +0 -7
  105. package/__mf/js/async/121.c3c0e54f.js +0 -2
  106. package/__mf/js/async/177.2fef2962.js +0 -1
  107. package/__mf/js/async/187.f5e8932b.js +0 -1
  108. package/__mf/js/async/192.c3dd56d5.js +0 -1
  109. package/__mf/js/async/2.60fa4a40.js +0 -1
  110. package/__mf/js/async/208.b9f374ad.js +0 -7
  111. package/__mf/js/async/208.b9f374ad.js.LICENSE.txt +0 -39
  112. package/__mf/js/async/235.d23c8ef0.js +0 -1
  113. package/__mf/js/async/274.72dfa9c8.js +0 -2
  114. package/__mf/js/async/356.8170c96d.js +0 -1
  115. package/__mf/js/async/392.b9ba5bf2.js +0 -2
  116. package/__mf/js/async/470.e09f33b7.js +0 -2
  117. package/__mf/js/async/491.85194549.js +0 -1
  118. package/__mf/js/async/518.2ac1df43.js +0 -38
  119. package/__mf/js/async/52.0d78de2b.js +0 -1
  120. package/__mf/js/async/546.5fecffa4.js +0 -3
  121. package/__mf/js/async/568.45da2c30.js +0 -1
  122. package/__mf/js/async/587.c9460696.js +0 -1
  123. package/__mf/js/async/588.0a1aa144.js +0 -1
  124. package/__mf/js/async/603.3b771310.js +0 -2
  125. package/__mf/js/async/616.79484ac8.js +0 -1
  126. package/__mf/js/async/655.2f794f77.js +0 -1
  127. package/__mf/js/async/694.0fb9ee5a.js +0 -2
  128. package/__mf/js/async/702.785cd635.js +0 -2
  129. package/__mf/js/async/71.8c6cf914.js +0 -1
  130. package/__mf/js/async/724.c45dcf5b.js +0 -1
  131. package/__mf/js/async/873.04a201bf.js +0 -1
  132. package/__mf/js/async/941.b89f8595.js +0 -2
  133. package/__mf/js/async/955.176fe200.js +0 -1
  134. package/__mf/js/async/968.2a9fb1a0.js +0 -1
  135. package/__mf/js/async/978.a9865b23.js +0 -1
  136. package/__mf/js/async/984.83bd5c6d.js +0 -22
  137. package/__mf/js/async/__federation_expose_TimeSeriesChart.0ab11cd4.js +0 -1
  138. package/__mf/js/async/lib-router.319c02cd.js +0 -2
  139. package/__mf/js/main.691eecd6.js +0 -7
  140. package/lib/cjs/GeneralSettingsEditor.js +0 -103
  141. package/lib/cjs/QuerySettingsEditor.js +0 -666
  142. package/lib/cjs/TimeSeriesChart.js +0 -50
  143. package/lib/cjs/TimeSeriesChartBase.js +0 -488
  144. package/lib/cjs/TimeSeriesChartPanel.js +0 -456
  145. package/lib/cjs/TimeSeriesExportAction.js +0 -124
  146. package/lib/cjs/VisualOptionsEditor.js +0 -161
  147. package/lib/cjs/YAxisOptionsEditor.js +0 -118
  148. package/lib/cjs/annotations/AnnotationTooltip.js +0 -370
  149. package/lib/cjs/bootstrap.js +0 -26
  150. package/lib/cjs/env.d.js +0 -14
  151. package/lib/cjs/getPluginModule.js +0 -39
  152. package/lib/cjs/index-federation.js +0 -55
  153. package/lib/cjs/index.js +0 -44
  154. package/lib/cjs/setup-tests.js +0 -19
  155. package/lib/cjs/test/mock-query-results.js +0 -403
  156. package/lib/cjs/time-series-chart-model.js +0 -225
  157. package/lib/cjs/utils/annotation.js +0 -37
  158. package/lib/cjs/utils/data-transform.js +0 -243
  159. package/lib/cjs/utils/palette-gen.js +0 -75
  160. package/lib/cjs/utils/palette.js +0 -83
  161. package/lib/cjs/utils/timezone-formatter.js +0 -48
  162. /package/__mf/css/async/{208.85c2cbf6.css → 463.85c2cbf6.css} +0 -0
  163. /package/__mf/js/async/{121.c3c0e54f.js.LICENSE.txt → 121.fde1320e.js.LICENSE.txt} +0 -0
  164. /package/__mf/js/async/{527.f97d1b86.js.LICENSE.txt → 182.9e1e293f.js.LICENSE.txt} +0 -0
  165. /package/__mf/js/async/{274.72dfa9c8.js.LICENSE.txt → 274.e4ed32f7.js.LICENSE.txt} +0 -0
  166. /package/__mf/js/async/{392.b9ba5bf2.js.LICENSE.txt → 392.8cb3dcaa.js.LICENSE.txt} +0 -0
  167. /package/__mf/js/async/{470.e09f33b7.js.LICENSE.txt → 470.beedcbcc.js.LICENSE.txt} +0 -0
  168. /package/__mf/js/async/{984.83bd5c6d.js.LICENSE.txt → 522.806db24f.js.LICENSE.txt} +0 -0
  169. /package/__mf/js/async/{603.3b771310.js.LICENSE.txt → 597.0c5bd6dd.js.LICENSE.txt} +0 -0
  170. /package/__mf/js/async/{702.785cd635.js.LICENSE.txt → 865.cb917066.js.LICENSE.txt} +0 -0
  171. /package/__mf/js/async/{941.b89f8595.js.LICENSE.txt → 941.3bb54150.js.LICENSE.txt} +0 -0
  172. /package/__mf/js/async/{lib-router.319c02cd.js.LICENSE.txt → lib-router.ecb51f08.js.LICENSE.txt} +0 -0
@@ -1,666 +0,0 @@
1
- // Copyright 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, "QuerySettingsEditor", {
18
- enumerable: true,
19
- get: function() {
20
- return QuerySettingsEditor;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _material = require("@mui/material");
25
- const _components = require("@perses-dev/components");
26
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
27
- const _DeleteOutline = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/DeleteOutline"));
28
- const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
29
- const _Close = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Close"));
30
- const _immer = require("immer");
31
- const _pluginsystem = require("@perses-dev/plugin-system");
32
- const _timeserieschartmodel = require("./time-series-chart-model");
33
- function _interop_require_default(obj) {
34
- return obj && obj.__esModule ? obj : {
35
- default: obj
36
- };
37
- }
38
- function _getRequireWildcardCache(nodeInterop) {
39
- if (typeof WeakMap !== "function") return null;
40
- var cacheBabelInterop = new WeakMap();
41
- var cacheNodeInterop = new WeakMap();
42
- return (_getRequireWildcardCache = function(nodeInterop) {
43
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
44
- })(nodeInterop);
45
- }
46
- function _interop_require_wildcard(obj, nodeInterop) {
47
- if (!nodeInterop && obj && obj.__esModule) {
48
- return obj;
49
- }
50
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
51
- return {
52
- default: obj
53
- };
54
- }
55
- var cache = _getRequireWildcardCache(nodeInterop);
56
- if (cache && cache.has(obj)) {
57
- return cache.get(obj);
58
- }
59
- var newObj = {
60
- __proto__: null
61
- };
62
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
63
- for(var key in obj){
64
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
65
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
66
- if (desc && (desc.get || desc.set)) {
67
- Object.defineProperty(newObj, key, desc);
68
- } else {
69
- newObj[key] = obj[key];
70
- }
71
- }
72
- }
73
- newObj.default = obj;
74
- if (cache) {
75
- cache.set(obj, newObj);
76
- }
77
- return newObj;
78
- }
79
- const DEFAULT_COLOR_VALUE = '#555';
80
- const NO_INDEX_AVAILABLE = -1; // invalid array index value used to represent the fact that no query index is available
81
- function QuerySettingsEditor(props) {
82
- const { onChange, value } = props;
83
- const querySettingsList = value.querySettings;
84
- const handleQuerySettingsChange = (newQuerySettings)=>{
85
- onChange((0, _immer.produce)(value, (draft)=>{
86
- draft.querySettings = newQuerySettings;
87
- }));
88
- };
89
- // Every time a new query settings input is added, we want to focus the recently added input
90
- const recentlyAddedInputRef = (0, _react.useRef)(null);
91
- const focusRef = (0, _react.useRef)(false);
92
- (0, _react.useEffect)(()=>{
93
- if (!recentlyAddedInputRef.current || !focusRef.current) return;
94
- recentlyAddedInputRef.current?.focus();
95
- focusRef.current = false;
96
- }, [
97
- querySettingsList?.length
98
- ]);
99
- const handleQueryIndexChange = (e, i)=>{
100
- if (querySettingsList !== undefined) {
101
- handleQuerySettingsChange((0, _immer.produce)(querySettingsList, (draft)=>{
102
- const querySettings = draft?.[i];
103
- if (querySettings) {
104
- querySettings.queryIndex = parseInt(e.target.value);
105
- }
106
- }));
107
- }
108
- };
109
- const handleColorModeChange = (e, i)=>{
110
- if (querySettingsList !== undefined) {
111
- handleQuerySettingsChange((0, _immer.produce)(querySettingsList, (draft)=>{
112
- if (draft !== undefined) {
113
- const querySettings = draft[i];
114
- if (querySettings) {
115
- const newColorMode = e.target.value;
116
- if (!newColorMode) {
117
- querySettings.colorMode = undefined;
118
- querySettings.colorValue = undefined;
119
- } else {
120
- querySettings.colorMode = newColorMode;
121
- }
122
- }
123
- }
124
- }));
125
- }
126
- };
127
- const handleColorValueChange = (colorValue, i)=>{
128
- if (querySettingsList !== undefined) {
129
- handleQuerySettingsChange((0, _immer.produce)(querySettingsList, (draft)=>{
130
- if (draft !== undefined) {
131
- const querySettings = draft[i];
132
- if (querySettings) {
133
- querySettings.colorValue = colorValue;
134
- }
135
- }
136
- }));
137
- }
138
- };
139
- const handleLineStyleChange = (lineStyle, i)=>{
140
- if (querySettingsList !== undefined) {
141
- handleQuerySettingsChange((0, _immer.produce)(querySettingsList, (draft)=>{
142
- if (draft !== undefined) {
143
- const querySettings = draft[i];
144
- if (querySettings) {
145
- querySettings.lineStyle = lineStyle;
146
- }
147
- }
148
- }));
149
- }
150
- };
151
- const handleAreaOpacityChange = (_, sliderValue, i)=>{
152
- const newValue = Array.isArray(sliderValue) ? sliderValue[0] : sliderValue;
153
- if (querySettingsList !== undefined) {
154
- handleQuerySettingsChange((0, _immer.produce)(querySettingsList, (draft)=>{
155
- if (draft !== undefined) {
156
- const querySettings = draft[i];
157
- if (querySettings) {
158
- querySettings.areaOpacity = newValue;
159
- }
160
- }
161
- }));
162
- }
163
- };
164
- // Helper function to update query settings at a specific index
165
- const updateQuerySettings = (i, updater)=>{
166
- if (querySettingsList !== undefined) {
167
- handleQuerySettingsChange((0, _immer.produce)(querySettingsList, (draft)=>{
168
- const qs = draft[i];
169
- if (qs) {
170
- updater(qs);
171
- }
172
- }));
173
- }
174
- };
175
- const deleteQuerySettingsInput = (i)=>{
176
- if (querySettingsList !== undefined) {
177
- const updatedQuerySettingsList = (0, _immer.produce)(querySettingsList, (draft)=>{
178
- draft.splice(i, 1);
179
- });
180
- handleQuerySettingsChange(updatedQuerySettingsList);
181
- }
182
- };
183
- const addColor = (i)=>{
184
- updateQuerySettings(i, (qs)=>{
185
- qs.colorMode = 'fixed';
186
- qs.colorValue = DEFAULT_COLOR_VALUE;
187
- });
188
- };
189
- const removeColor = (i)=>{
190
- updateQuerySettings(i, (qs)=>{
191
- qs.colorMode = undefined;
192
- qs.colorValue = undefined;
193
- });
194
- };
195
- const addLineStyle = (i)=>{
196
- updateQuerySettings(i, (qs)=>{
197
- qs.lineStyle = 'solid';
198
- });
199
- };
200
- const removeLineStyle = (i)=>{
201
- updateQuerySettings(i, (qs)=>{
202
- qs.lineStyle = undefined;
203
- });
204
- };
205
- const addAreaOpacity = (i)=>{
206
- updateQuerySettings(i, (qs)=>{
207
- qs.areaOpacity = _timeserieschartmodel.DEFAULT_AREA_OPACITY;
208
- });
209
- };
210
- const removeAreaOpacity = (i)=>{
211
- updateQuerySettings(i, (qs)=>{
212
- qs.areaOpacity = undefined;
213
- });
214
- };
215
- const addFormat = (i)=>{
216
- updateQuerySettings(i, (qs)=>{
217
- qs.format = {
218
- unit: 'decimal',
219
- shortValues: true
220
- };
221
- });
222
- };
223
- const removeFormat = (i)=>{
224
- updateQuerySettings(i, (qs)=>{
225
- qs.format = undefined;
226
- });
227
- };
228
- const addStack = (i)=>{
229
- updateQuerySettings(i, (qs)=>{
230
- qs.stack = false;
231
- });
232
- };
233
- const removeStack = (i)=>{
234
- updateQuerySettings(i, (qs)=>{
235
- qs.stack = undefined;
236
- });
237
- };
238
- const handleStackChange = (i, checked)=>{
239
- updateQuerySettings(i, (qs)=>{
240
- qs.stack = checked;
241
- });
242
- };
243
- const handleFormatChange = (i, format)=>{
244
- updateQuerySettings(i, (qs)=>{
245
- qs.format = format;
246
- });
247
- };
248
- const addNegativeY = (i)=>{
249
- updateQuerySettings(i, (qs)=>{
250
- qs.negativeY = true;
251
- });
252
- };
253
- const removeNegativeY = (i)=>{
254
- updateQuerySettings(i, (qs)=>{
255
- qs.negativeY = undefined;
256
- });
257
- };
258
- const { queryDefinitions } = (0, _pluginsystem.useDataQueriesContext)();
259
- const queryCount = queryDefinitions.length;
260
- const queryNames = (0, _react.useMemo)(()=>(0, _pluginsystem.generateQueryNames)(queryDefinitions), [
261
- queryDefinitions
262
- ]);
263
- // Compute the list of query indexes for which query settings are not already defined.
264
- // This is to avoid already-booked indexes to still be selectable in the dropdown(s)
265
- const availableQueryIndexes = (0, _react.useMemo)(()=>{
266
- const bookedQueryIndexes = querySettingsList?.map((querySettings)=>querySettings.queryIndex) ?? [];
267
- const allQueryIndexes = Array.from({
268
- length: queryCount
269
- }, (_, i)=>i);
270
- return allQueryIndexes.filter((_, queryIndex)=>!bookedQueryIndexes.includes(queryIndex));
271
- }, [
272
- querySettingsList,
273
- queryCount
274
- ]);
275
- const firstAvailableQueryIndex = (0, _react.useMemo)(()=>{
276
- return availableQueryIndexes[0] ?? NO_INDEX_AVAILABLE;
277
- }, [
278
- availableQueryIndexes
279
- ]);
280
- const defaultQuerySettings = {
281
- queryIndex: firstAvailableQueryIndex
282
- };
283
- const addQuerySettingsInput = ()=>{
284
- focusRef.current = true;
285
- if (querySettingsList === undefined) {
286
- handleQuerySettingsChange([
287
- defaultQuerySettings
288
- ]);
289
- } else {
290
- handleQuerySettingsChange((0, _immer.produce)(querySettingsList, (draft)=>{
291
- draft.push(defaultQuerySettings);
292
- }));
293
- }
294
- };
295
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
296
- children: [
297
- queryCount === 0 ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
298
- mb: 2,
299
- fontStyle: "italic",
300
- children: "No query defined"
301
- }) : querySettingsList?.map((querySettings, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(QuerySettingsInput, {
302
- inputRef: i === querySettingsList.length - 1 ? recentlyAddedInputRef : undefined,
303
- querySettings: querySettings,
304
- availableQueryIndexes: availableQueryIndexes,
305
- queryNames: queryNames,
306
- onQueryIndexChange: (e)=>{
307
- handleQueryIndexChange(e, i);
308
- },
309
- onColorModeChange: (e)=>handleColorModeChange(e, i),
310
- onColorValueChange: (color)=>handleColorValueChange(color, i),
311
- onLineStyleChange: (lineStyle)=>handleLineStyleChange(lineStyle, i),
312
- onAreaOpacityChange: (event, value)=>handleAreaOpacityChange(event, value, i),
313
- onDelete: ()=>{
314
- deleteQuerySettingsInput(i);
315
- },
316
- onAddColor: ()=>addColor(i),
317
- onRemoveColor: ()=>removeColor(i),
318
- onAddLineStyle: ()=>addLineStyle(i),
319
- onRemoveLineStyle: ()=>removeLineStyle(i),
320
- onAddAreaOpacity: ()=>addAreaOpacity(i),
321
- onRemoveAreaOpacity: ()=>removeAreaOpacity(i),
322
- onAddFormat: ()=>addFormat(i),
323
- onRemoveFormat: ()=>removeFormat(i),
324
- onFormatChange: (format)=>handleFormatChange(i, format),
325
- onAddNegativeY: ()=>addNegativeY(i),
326
- onRemoveNegativeY: ()=>removeNegativeY(i),
327
- onAddStack: ()=>addStack(i),
328
- onRemoveStack: ()=>removeStack(i),
329
- onStackChange: (checked)=>handleStackChange(i, checked)
330
- }, i)),
331
- queryCount > 0 && firstAvailableQueryIndex !== NO_INDEX_AVAILABLE && /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
332
- variant: "contained",
333
- startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {}),
334
- sx: {
335
- marginTop: 1
336
- },
337
- onClick: addQuerySettingsInput,
338
- children: "Add Query Settings"
339
- })
340
- ]
341
- });
342
- }
343
- function QuerySettingsInput({ querySettings: { queryIndex, colorMode, colorValue, lineStyle, areaOpacity, format, negativeY, stack }, availableQueryIndexes, queryNames, onQueryIndexChange, onColorModeChange, onColorValueChange, onLineStyleChange, onAreaOpacityChange, onDelete, inputRef, onAddColor: onAddColor, onRemoveColor: onRemoveColor, onAddLineStyle, onRemoveLineStyle, onAddAreaOpacity, onRemoveAreaOpacity, onAddFormat, onRemoveFormat, onFormatChange, onAddNegativeY, onRemoveNegativeY, onAddStack, onRemoveStack, onStackChange }) {
344
- // current query index should also be selectable
345
- const selectableQueryIndexes = availableQueryIndexes.concat(queryIndex).sort((a, b)=>a - b);
346
- // State for dropdown menu
347
- const [anchorEl, setAnchorEl] = (0, _react.useState)(null);
348
- // Calculate available options
349
- const availableOptions = (0, _react.useMemo)(()=>{
350
- const options = [];
351
- if (!colorMode) options.push({
352
- key: 'color',
353
- label: 'Color',
354
- action: onAddColor
355
- });
356
- if (!lineStyle) options.push({
357
- key: 'lineStyle',
358
- label: 'Line Style',
359
- action: onAddLineStyle
360
- });
361
- if (areaOpacity === undefined) options.push({
362
- key: 'opacity',
363
- label: 'Opacity',
364
- action: onAddAreaOpacity
365
- });
366
- if (format === undefined) options.push({
367
- key: 'format',
368
- label: 'Format',
369
- action: onAddFormat
370
- });
371
- if (!negativeY) options.push({
372
- key: 'negativeY',
373
- label: 'Negative Y',
374
- action: onAddNegativeY
375
- });
376
- if (stack === undefined) options.push({
377
- key: 'stack',
378
- label: 'Stack',
379
- action: onAddStack
380
- });
381
- return options;
382
- }, [
383
- colorMode,
384
- lineStyle,
385
- areaOpacity,
386
- format,
387
- negativeY,
388
- stack,
389
- onAddColor,
390
- onAddLineStyle,
391
- onAddAreaOpacity,
392
- onAddFormat,
393
- onAddNegativeY,
394
- onAddStack
395
- ]);
396
- const handleAddMenuClick = (event)=>{
397
- if (availableOptions.length === 1 && availableOptions[0]) {
398
- // If only one option left, add it directly
399
- availableOptions[0].action();
400
- } else {
401
- // Show dropdown
402
- setAnchorEl(event.currentTarget);
403
- }
404
- };
405
- const handleMenuClose = ()=>{
406
- setAnchorEl(null);
407
- };
408
- const handleMenuItemClick = (action)=>{
409
- action();
410
- handleMenuClose();
411
- };
412
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
413
- sx: {
414
- borderBottom: '1px solid',
415
- borderColor: 'divider',
416
- borderRadius: 1,
417
- p: 2,
418
- display: 'flex',
419
- flexWrap: 'nowrap',
420
- flexDirection: 'row'
421
- },
422
- children: [
423
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
424
- direction: "row",
425
- alignItems: "center",
426
- sx: {
427
- flexWrap: 'wrap',
428
- gap: 2,
429
- flexGrow: 1
430
- },
431
- children: [
432
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
433
- select: true,
434
- inputRef: inputRef,
435
- value: queryIndex,
436
- label: "Query",
437
- onChange: onQueryIndexChange,
438
- sx: {
439
- minWidth: '75px'
440
- },
441
- children: selectableQueryIndexes.map((qi)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
442
- value: qi,
443
- children: queryNames[qi] ?? `#${qi + 1}`
444
- }, `query-${qi}`))
445
- }),
446
- colorMode && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
447
- label: "Color",
448
- onRemove: onRemoveColor,
449
- children: [
450
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.TextField, {
451
- select: true,
452
- value: colorMode,
453
- onChange: onColorModeChange,
454
- size: "small",
455
- sx: {
456
- flexGrow: 1
457
- },
458
- children: [
459
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
460
- value: "fixed",
461
- children: "Fixed"
462
- }),
463
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.MenuItem, {
464
- value: "fixed-single",
465
- children: "Fixed (single series)"
466
- })
467
- ]
468
- }),
469
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsColorPicker, {
470
- label: queryNames[queryIndex] ?? `Query n°${queryIndex + 1}`,
471
- color: colorValue || DEFAULT_COLOR_VALUE,
472
- onColorChange: onColorValueChange
473
- })
474
- ]
475
- }),
476
- lineStyle && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
477
- label: "Line Style",
478
- onRemove: onRemoveLineStyle,
479
- children: [
480
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButtonGroup, {
481
- color: "primary",
482
- exclusive: true,
483
- value: lineStyle,
484
- onChange: (__, newValue)=>{
485
- if (newValue !== null) {
486
- onLineStyleChange(newValue);
487
- }
488
- },
489
- size: "small",
490
- children: Object.entries(_timeserieschartmodel.LINE_STYLE_CONFIG).map(([styleValue, config])=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.ToggleButton, {
491
- value: styleValue,
492
- "aria-label": `${styleValue} line style`,
493
- children: config.label
494
- }, styleValue))
495
- }),
496
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
497
- sx: {
498
- flexGrow: 1
499
- }
500
- })
501
- ]
502
- }),
503
- areaOpacity !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
504
- label: "Opacity",
505
- onRemove: onRemoveAreaOpacity,
506
- children: [
507
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {}),
508
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Slider, {
509
- value: areaOpacity,
510
- valueLabelDisplay: "auto",
511
- step: _timeserieschartmodel.OPACITY_CONFIG.step,
512
- marks: true,
513
- min: _timeserieschartmodel.OPACITY_CONFIG.min,
514
- max: _timeserieschartmodel.OPACITY_CONFIG.max,
515
- onChange: onAreaOpacityChange,
516
- sx: {
517
- flexGrow: 1
518
- }
519
- })
520
- ]
521
- }),
522
- format !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsx)(SettingsSection, {
523
- label: "Format",
524
- onRemove: onRemoveFormat,
525
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
526
- sx: {
527
- minWidth: '180px',
528
- display: 'flex',
529
- gap: 1,
530
- flexDirection: 'column'
531
- },
532
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
533
- value: format,
534
- onChange: onFormatChange
535
- })
536
- })
537
- }),
538
- negativeY && /*#__PURE__*/ (0, _jsxruntime.jsx)(SettingsSection, {
539
- label: "Negative Y",
540
- onRemove: onRemoveNegativeY,
541
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
542
- variant: "body2",
543
- color: "text.secondary",
544
- sx: {
545
- flexGrow: 1,
546
- py: 0.5
547
- },
548
- children: "Series rendered below the X axis"
549
- })
550
- }),
551
- stack !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsxs)(SettingsSection, {
552
- label: "Stack",
553
- onRemove: onRemoveStack,
554
- children: [
555
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
556
- checked: stack,
557
- onChange: (e)=>onStackChange(e.target.checked),
558
- slotProps: {
559
- input: {
560
- 'aria-label': 'stack override'
561
- }
562
- }
563
- }),
564
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
565
- sx: {
566
- flexGrow: 1
567
- }
568
- })
569
- ]
570
- }),
571
- availableOptions.length > 0 && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
572
- children: [
573
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
574
- onClick: handleAddMenuClick,
575
- "aria-label": "Add option",
576
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {})
577
- }),
578
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Menu, {
579
- anchorEl: anchorEl,
580
- open: Boolean(anchorEl),
581
- onClose: handleMenuClose,
582
- anchorOrigin: {
583
- vertical: 'bottom',
584
- horizontal: 'left'
585
- },
586
- children: availableOptions.map((option)=>/*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.MenuItem, {
587
- onClick: ()=>handleMenuItemClick(option.action),
588
- sx: {
589
- minWidth: '120px'
590
- },
591
- children: [
592
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {
593
- sx: {
594
- mr: 1,
595
- fontSize: '1rem'
596
- }
597
- }),
598
- option.label
599
- ]
600
- }, option.key))
601
- })
602
- ]
603
- })
604
- ]
605
- }),
606
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
607
- sx: {
608
- display: 'flex',
609
- alignItems: 'center',
610
- justifyContent: 'center'
611
- },
612
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
613
- "aria-label": `delete settings for ${queryNames[queryIndex] ?? `query n°${queryIndex + 1}`}`,
614
- onClick: onDelete,
615
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_DeleteOutline.default, {})
616
- })
617
- })
618
- ]
619
- });
620
- }
621
- // Reusable section component
622
- function SettingsSection(props) {
623
- const { label, children, onRemove } = props;
624
- const theme = (0, _material.useTheme)();
625
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
626
- sx: {
627
- position: 'relative',
628
- minWidth: '250px'
629
- },
630
- children: [
631
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
632
- variant: "caption",
633
- sx: {
634
- position: 'absolute',
635
- top: -8,
636
- left: 12,
637
- backgroundColor: theme.palette.background.code,
638
- px: 0.5,
639
- color: 'text.secondary',
640
- zIndex: 1
641
- },
642
- children: label
643
- }),
644
- /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
645
- direction: "row",
646
- alignItems: "center",
647
- spacing: 1,
648
- sx: {
649
- border: '1px solid',
650
- borderColor: 'divider',
651
- borderRadius: 1,
652
- p: 1
653
- },
654
- children: [
655
- children,
656
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.IconButton, {
657
- size: "small",
658
- onClick: onRemove,
659
- "aria-label": `Remove ${label}`,
660
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Close.default, {})
661
- })
662
- ]
663
- })
664
- ]
665
- });
666
- }