@perses-dev/table-plugin 0.13.0 → 0.14.0-beta.1

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 (211) hide show
  1. package/__mf/js/{Table.73b9cec1.js → Table.646f97de.js} +3 -3
  2. package/__mf/js/async/11.976870d0.js +7 -0
  3. package/__mf/js/async/11.976870d0.js.LICENSE.txt +102 -0
  4. package/__mf/js/async/121.b3a4c6cf.js +2 -0
  5. package/__mf/js/async/153.fa68a9e4.js +1 -0
  6. package/__mf/js/async/186.ab1e0cb3.js +2 -0
  7. package/__mf/js/async/192.942516a2.js +1 -0
  8. package/__mf/js/async/2.6b27d33f.js +1 -0
  9. package/__mf/js/async/235.c5bac291.js +1 -0
  10. package/__mf/js/async/274.f7dabfa6.js +2 -0
  11. package/__mf/js/async/321.96f362a6.js +1 -0
  12. package/__mf/js/async/35.ba7c1b06.js +1 -0
  13. package/__mf/js/async/356.d7fe5d24.js +1 -0
  14. package/__mf/js/async/392.e853a818.js +2 -0
  15. package/__mf/js/async/413.d44db4b1.js +1 -0
  16. package/__mf/js/async/465.8425c17a.js +1 -0
  17. package/__mf/js/async/470.21434f20.js +2 -0
  18. package/__mf/js/async/522.d6a7c203.js +22 -0
  19. package/__mf/js/async/534.aff242e9.js +1 -0
  20. package/__mf/js/async/54.e77ec040.js +1 -0
  21. package/__mf/js/async/587.0ff26337.js +1 -0
  22. package/__mf/js/async/616.4e891cf9.js +1 -0
  23. package/__mf/js/async/663.b3778d4c.js +1 -0
  24. package/__mf/js/async/700.ccacc909.js +3 -0
  25. package/__mf/js/async/{868.507e984c.js → 741.7feaa0ba.js} +6 -6
  26. package/__mf/js/async/862.4c658639.js +2 -0
  27. package/__mf/js/async/865.b9eb3de4.js +1 -0
  28. package/__mf/js/async/923.87e55609.js +1 -0
  29. package/__mf/js/async/941.08c16cb2.js +2 -0
  30. package/__mf/js/async/968.b7fe9818.js +1 -0
  31. package/__mf/js/async/985.6129a36c.js +37 -0
  32. package/__mf/js/async/__federation_expose_Table.f8d0feb7.js +1 -0
  33. package/__mf/js/async/lib-router.020a2a16.js +2 -0
  34. package/__mf/js/{main.7b15c841.js → main.276cd542.js} +2 -2
  35. package/lib/Table.d.ts +3 -3
  36. package/lib/Table.d.ts.map +1 -1
  37. package/lib/Table.js +4 -4
  38. package/lib/Table.js.map +1 -1
  39. package/lib/TableExportAction.d.ts +3 -3
  40. package/lib/TableExportAction.d.ts.map +1 -1
  41. package/lib/TableExportAction.js +6 -6
  42. package/lib/TableExportAction.js.map +1 -1
  43. package/lib/bootstrap.js +2 -2
  44. package/lib/components/CellsEditor/CellsEditor.d.ts +2 -2
  45. package/lib/components/CellsEditor/CellsEditor.d.ts.map +1 -1
  46. package/lib/components/CellsEditor/CellsEditor.js +1 -1
  47. package/lib/components/CellsEditor/CellsEditor.js.map +1 -1
  48. package/lib/components/CellsEditor/index.js +1 -1
  49. package/lib/components/CellsEditor/index.js.map +1 -1
  50. package/lib/components/ColumnsEditor/ColumnEditor.d.ts +5 -4
  51. package/lib/components/ColumnsEditor/ColumnEditor.d.ts.map +1 -1
  52. package/lib/components/ColumnsEditor/ColumnEditor.js +29 -15
  53. package/lib/components/ColumnsEditor/ColumnEditor.js.map +1 -1
  54. package/lib/components/ColumnsEditor/ColumnEditorContainer.d.ts +3 -3
  55. package/lib/components/ColumnsEditor/ColumnEditorContainer.d.ts.map +1 -1
  56. package/lib/components/ColumnsEditor/ColumnEditorContainer.js +11 -10
  57. package/lib/components/ColumnsEditor/ColumnEditorContainer.js.map +1 -1
  58. package/lib/components/ColumnsEditor/ColumnsEditor.d.ts +4 -3
  59. package/lib/components/ColumnsEditor/ColumnsEditor.d.ts.map +1 -1
  60. package/lib/components/ColumnsEditor/ColumnsEditor.js +7 -6
  61. package/lib/components/ColumnsEditor/ColumnsEditor.js.map +1 -1
  62. package/lib/components/ColumnsEditor/DataLinkEditorDialog.d.ts +2 -2
  63. package/lib/components/ColumnsEditor/DataLinkEditorDialog.d.ts.map +1 -1
  64. package/lib/components/ColumnsEditor/DataLinkEditorDialog.js +4 -4
  65. package/lib/components/ColumnsEditor/DataLinkEditorDialog.js.map +1 -1
  66. package/lib/components/ColumnsEditor/EmbeddedPanelOptionsEditor.d.ts +2 -2
  67. package/lib/components/ColumnsEditor/EmbeddedPanelOptionsEditor.d.ts.map +1 -1
  68. package/lib/components/ColumnsEditor/EmbeddedPanelOptionsEditor.js +4 -4
  69. package/lib/components/ColumnsEditor/EmbeddedPanelOptionsEditor.js.map +1 -1
  70. package/lib/components/ColumnsEditor/index.js +3 -3
  71. package/lib/components/ColumnsEditor/index.js.map +1 -1
  72. package/lib/components/ConditionalPanel.d.ts +3 -3
  73. package/lib/components/ConditionalPanel.d.ts.map +1 -1
  74. package/lib/components/ConditionalPanel.js +7 -7
  75. package/lib/components/ConditionalPanel.js.map +1 -1
  76. package/lib/components/EmbeddedPanel.d.ts +3 -3
  77. package/lib/components/EmbeddedPanel.d.ts.map +1 -1
  78. package/lib/components/EmbeddedPanel.js +4 -4
  79. package/lib/components/EmbeddedPanel.js.map +1 -1
  80. package/lib/components/TableCellsEditor.d.ts +3 -3
  81. package/lib/components/TableCellsEditor.d.ts.map +1 -1
  82. package/lib/components/TableCellsEditor.js +1 -1
  83. package/lib/components/TableCellsEditor.js.map +1 -1
  84. package/lib/components/TableColumnsEditor.d.ts +3 -3
  85. package/lib/components/TableColumnsEditor.d.ts.map +1 -1
  86. package/lib/components/TableColumnsEditor.js +3 -2
  87. package/lib/components/TableColumnsEditor.js.map +1 -1
  88. package/lib/components/TableItemSelectionActionsEditor.d.ts +2 -2
  89. package/lib/components/TableItemSelectionActionsEditor.d.ts.map +1 -1
  90. package/lib/components/TableItemSelectionActionsEditor.js +2 -2
  91. package/lib/components/TableItemSelectionActionsEditor.js.map +1 -1
  92. package/lib/components/TablePanel.d.ts +4 -4
  93. package/lib/components/TablePanel.d.ts.map +1 -1
  94. package/lib/components/TablePanel.js +196 -99
  95. package/lib/components/TablePanel.js.map +1 -1
  96. package/lib/components/TableSettingsEditor.d.ts +2 -2
  97. package/lib/components/TableSettingsEditor.d.ts.map +1 -1
  98. package/lib/components/TableSettingsEditor.js +16 -2
  99. package/lib/components/TableSettingsEditor.js.map +1 -1
  100. package/lib/components/TableTransformsEditor.d.ts +2 -2
  101. package/lib/components/TableTransformsEditor.d.ts.map +1 -1
  102. package/lib/components/TableTransformsEditor.js +2 -2
  103. package/lib/components/TableTransformsEditor.js.map +1 -1
  104. package/lib/components/index.js +9 -9
  105. package/lib/components/index.js.map +1 -1
  106. package/lib/getPluginModule.d.ts +1 -1
  107. package/lib/getPluginModule.d.ts.map +1 -1
  108. package/lib/getPluginModule.js +3 -1
  109. package/lib/getPluginModule.js.map +1 -1
  110. package/lib/index-federation.js +1 -1
  111. package/lib/index.js +4 -4
  112. package/lib/index.js.map +1 -1
  113. package/lib/models/index.js +2 -2
  114. package/lib/models/index.js.map +1 -1
  115. package/lib/models/model.d.ts +1 -1
  116. package/lib/models/model.d.ts.map +1 -1
  117. package/lib/models/model.js.map +1 -1
  118. package/lib/models/table-model.d.ts +4 -3
  119. package/lib/models/table-model.d.ts.map +1 -1
  120. package/lib/models/table-model.js +2 -2
  121. package/lib/models/table-model.js.map +1 -1
  122. package/lib/setup-tests.d.ts +1 -1
  123. package/lib/setup-tests.d.ts.map +1 -1
  124. package/lib/setup-tests.js +8 -2
  125. package/lib/setup-tests.js.map +1 -1
  126. package/lib/table-data-utils.d.ts +3 -3
  127. package/lib/table-data-utils.d.ts.map +1 -1
  128. package/lib/table-data-utils.js.map +1 -1
  129. package/lib/test/mock-query-results.d.ts +1 -1
  130. package/lib/test/mock-query-results.d.ts.map +1 -1
  131. package/lib/test/mock-query-results.js.map +1 -1
  132. package/mf-manifest.json +42 -84
  133. package/mf-stats.json +46 -93
  134. package/package.json +11 -11
  135. package/__mf/js/async/1432.4e515509.js +0 -1
  136. package/__mf/js/async/1589.124ce93d.js +0 -2
  137. package/__mf/js/async/1589.124ce93d.js.LICENSE.txt +0 -37
  138. package/__mf/js/async/1616.4828085d.js +0 -1
  139. package/__mf/js/async/2043.1f09864b.js +0 -2
  140. package/__mf/js/async/2043.1f09864b.js.LICENSE.txt +0 -24
  141. package/__mf/js/async/2082.231e8397.js +0 -1
  142. package/__mf/js/async/2842.a52597e6.js +0 -1
  143. package/__mf/js/async/392.b6035b41.js +0 -2
  144. package/__mf/js/async/3981.52e94742.js +0 -3
  145. package/__mf/js/async/4014.cf88a118.js +0 -7
  146. package/__mf/js/async/4014.cf88a118.js.LICENSE.txt +0 -39
  147. package/__mf/js/async/4121.e7df36d6.js +0 -2
  148. package/__mf/js/async/5002.3eb39a8c.js +0 -1
  149. package/__mf/js/async/5021.c663603d.js +0 -1
  150. package/__mf/js/async/5071.839a8f1a.js +0 -1
  151. package/__mf/js/async/5481.6496fac9.js +0 -2
  152. package/__mf/js/async/5587.a8a428db.js +0 -1
  153. package/__mf/js/async/6274.8edae86d.js +0 -2
  154. package/__mf/js/async/629.8cff215d.js +0 -1
  155. package/__mf/js/async/6811.9d4b123a.js +0 -38
  156. package/__mf/js/async/7177.e0e5ba2f.js +0 -1
  157. package/__mf/js/async/7192.692181c8.js +0 -1
  158. package/__mf/js/async/7413.c9310b8a.js +0 -1
  159. package/__mf/js/async/7968.3a9a982e.js +0 -1
  160. package/__mf/js/async/7978.116e4d81.js +0 -1
  161. package/__mf/js/async/7984.a8edc213.js +0 -22
  162. package/__mf/js/async/8356.152d5686.js +0 -1
  163. package/__mf/js/async/8470.b9762117.js +0 -2
  164. package/__mf/js/async/873.264fedc9.js +0 -1
  165. package/__mf/js/async/9051.c4deebd7.js +0 -1
  166. package/__mf/js/async/9235.c67cdb1d.js +0 -1
  167. package/__mf/js/async/941.cc458a98.js +0 -2
  168. package/__mf/js/async/9588.d23e2ed3.js +0 -1
  169. package/__mf/js/async/9701.9c4cea02.js +0 -1
  170. package/__mf/js/async/__federation_expose_Table.5d0cfb46.js +0 -1
  171. package/__mf/js/async/lib-router.3493bbf9.js +0 -2
  172. package/lib/cjs/Table.js +0 -62
  173. package/lib/cjs/TableExportAction.js +0 -180
  174. package/lib/cjs/bootstrap.js +0 -26
  175. package/lib/cjs/components/CellsEditor/CellsEditor.js +0 -30
  176. package/lib/cjs/components/CellsEditor/index.js +0 -30
  177. package/lib/cjs/components/ColumnsEditor/ColumnEditor.js +0 -289
  178. package/lib/cjs/components/ColumnsEditor/ColumnEditorContainer.js +0 -152
  179. package/lib/cjs/components/ColumnsEditor/ColumnsEditor.js +0 -108
  180. package/lib/cjs/components/ColumnsEditor/DataLinkEditorDialog.js +0 -139
  181. package/lib/cjs/components/ColumnsEditor/EmbeddedPanelOptionsEditor.js +0 -124
  182. package/lib/cjs/components/ColumnsEditor/index.js +0 -32
  183. package/lib/cjs/components/ConditionalPanel.js +0 -367
  184. package/lib/cjs/components/EmbeddedPanel.js +0 -52
  185. package/lib/cjs/components/TableCellsEditor.js +0 -36
  186. package/lib/cjs/components/TableColumnsEditor.js +0 -36
  187. package/lib/cjs/components/TableItemSelectionActionsEditor.js +0 -44
  188. package/lib/cjs/components/TablePanel.js +0 -845
  189. package/lib/cjs/components/TableSettingsEditor.js +0 -144
  190. package/lib/cjs/components/TableTransformsEditor.js +0 -36
  191. package/lib/cjs/components/index.js +0 -38
  192. package/lib/cjs/env.d.js +0 -14
  193. package/lib/cjs/getPluginModule.js +0 -39
  194. package/lib/cjs/index-federation.js +0 -55
  195. package/lib/cjs/index.js +0 -39
  196. package/lib/cjs/models/index.js +0 -31
  197. package/lib/cjs/models/model.js +0 -16
  198. package/lib/cjs/models/table-model.js +0 -278
  199. package/lib/cjs/setup-tests.js +0 -19
  200. package/lib/cjs/table-data-utils.js +0 -84
  201. package/lib/cjs/test/mock-query-results.js +0 -524
  202. /package/__mf/css/async/{4014.85c2cbf6.css → 11.85c2cbf6.css} +0 -0
  203. /package/__mf/js/async/{4121.e7df36d6.js.LICENSE.txt → 121.b3a4c6cf.js.LICENSE.txt} +0 -0
  204. /package/__mf/js/async/{6274.8edae86d.js.LICENSE.txt → 274.f7dabfa6.js.LICENSE.txt} +0 -0
  205. /package/__mf/js/async/{392.b6035b41.js.LICENSE.txt → 392.e853a818.js.LICENSE.txt} +0 -0
  206. /package/__mf/js/async/{8470.b9762117.js.LICENSE.txt → 470.21434f20.js.LICENSE.txt} +0 -0
  207. /package/__mf/js/async/{7984.a8edc213.js.LICENSE.txt → 522.d6a7c203.js.LICENSE.txt} +0 -0
  208. /package/__mf/js/async/{868.507e984c.js.LICENSE.txt → 741.7feaa0ba.js.LICENSE.txt} +0 -0
  209. /package/__mf/js/async/{5481.6496fac9.js.LICENSE.txt → 862.4c658639.js.LICENSE.txt} +0 -0
  210. /package/__mf/js/async/{941.cc458a98.js.LICENSE.txt → 941.08c16cb2.js.LICENSE.txt} +0 -0
  211. /package/__mf/js/async/{lib-router.3493bbf9.js.LICENSE.txt → lib-router.020a2a16.js.LICENSE.txt} +0 -0
@@ -1,278 +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
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get createInitialTableOptions () {
25
- return createInitialTableOptions;
26
- },
27
- get evaluateCondition () {
28
- return evaluateCondition;
29
- },
30
- get evaluateConditionalFormatting () {
31
- return evaluateConditionalFormatting;
32
- },
33
- get formatCellDisplay () {
34
- return formatCellDisplay;
35
- },
36
- get renderConditionEditor () {
37
- return renderConditionEditor;
38
- }
39
- });
40
- const _react = /*#__PURE__*/ _interop_require_default(require("react"));
41
- const _material = require("@mui/material");
42
- function _interop_require_default(obj) {
43
- return obj && obj.__esModule ? obj : {
44
- default: obj
45
- };
46
- }
47
- function createInitialTableOptions() {
48
- return {
49
- density: 'standard',
50
- enableFiltering: true
51
- };
52
- }
53
- function parseRangeBound(rawValue) {
54
- const trimmed = rawValue.trim();
55
- if (trimmed === '') {
56
- return undefined;
57
- }
58
- const parsed = Number(trimmed);
59
- return Number.isNaN(parsed) ? undefined : parsed;
60
- }
61
- function formatCellDisplay(value, setting, defaultText) {
62
- const baseText = setting.text || defaultText || String(value);
63
- const displayText = `${setting.prefix ?? ''}${baseText}${setting.suffix ?? ''}`;
64
- return {
65
- text: displayText,
66
- textColor: setting.textColor,
67
- backgroundColor: setting.backgroundColor
68
- };
69
- }
70
- function evaluateCondition(condition, value) {
71
- switch(condition.kind){
72
- case 'Value':
73
- return condition.spec?.value === String(value);
74
- case 'Range':
75
- {
76
- if (Number.isNaN(Number(value))) return false;
77
- const numericValue = Number(value);
78
- // Both min and max defined
79
- if (condition.spec?.min !== undefined && condition.spec?.max !== undefined) {
80
- return numericValue >= +condition.spec.min && numericValue <= +condition.spec.max;
81
- }
82
- // Only min defined
83
- if (condition.spec?.min !== undefined) {
84
- return numericValue >= +condition.spec.min;
85
- }
86
- // Only max defined
87
- if (condition.spec?.max !== undefined) {
88
- return numericValue <= +condition.spec.max;
89
- }
90
- return false;
91
- }
92
- case 'Regex':
93
- if (!condition.spec?.expr) return false;
94
- try {
95
- const regex = new RegExp(condition.spec.expr);
96
- return regex.test(String(value));
97
- } catch {
98
- return false; // Invalid regex
99
- }
100
- case 'Misc':
101
- switch(condition.spec?.value){
102
- case 'empty':
103
- return value === '';
104
- case 'null':
105
- return value === null || value === undefined;
106
- case 'NaN':
107
- return Number.isNaN(value);
108
- case 'true':
109
- return value === true;
110
- case 'false':
111
- return value === false;
112
- default:
113
- return false;
114
- }
115
- default:
116
- return false;
117
- }
118
- }
119
- function evaluateConditionalFormatting(value, settings) {
120
- for (const setting of settings){
121
- if (evaluateCondition(setting.condition, value)) {
122
- // Handle special default text cases
123
- let defaultText;
124
- if (setting.condition.kind === 'Misc') {
125
- switch(setting.condition.spec?.value){
126
- case 'null':
127
- defaultText = 'null';
128
- break;
129
- case 'NaN':
130
- defaultText = 'NaN';
131
- break;
132
- }
133
- }
134
- return formatCellDisplay(value, setting, defaultText);
135
- }
136
- }
137
- return undefined; // No conditions matched
138
- }
139
- function renderConditionEditor(condition, onChange, size = 'small') {
140
- if (condition.kind === 'Value') {
141
- return _react.default.createElement(_material.TextField, {
142
- label: 'Value',
143
- placeholder: 'Exact value',
144
- value: condition.spec?.value ?? '',
145
- onChange: (e)=>onChange({
146
- ...condition,
147
- spec: {
148
- value: e.target.value
149
- }
150
- }),
151
- fullWidth: true,
152
- size: size
153
- });
154
- } else if (condition.kind === 'Range') {
155
- return _react.default.createElement(_material.Stack, {
156
- gap: 1,
157
- direction: 'row'
158
- }, [
159
- _react.default.createElement(_material.TextField, {
160
- key: 'min',
161
- label: 'From',
162
- placeholder: 'Start of range',
163
- value: condition.spec?.min ?? '',
164
- onChange: (e)=>{
165
- const nextMin = parseRangeBound(e.target.value);
166
- onChange({
167
- ...condition,
168
- spec: {
169
- ...condition.spec,
170
- min: nextMin
171
- }
172
- });
173
- },
174
- type: 'number',
175
- slotProps: {
176
- htmlInput: {
177
- step: 'any'
178
- }
179
- },
180
- fullWidth: true,
181
- size: size
182
- }),
183
- _react.default.createElement(_material.TextField, {
184
- key: 'max',
185
- label: 'To',
186
- placeholder: 'End of range (inclusive)',
187
- value: condition.spec?.max ?? '',
188
- onChange: (e)=>{
189
- const nextMax = parseRangeBound(e.target.value);
190
- onChange({
191
- ...condition,
192
- spec: {
193
- ...condition.spec,
194
- max: nextMax
195
- }
196
- });
197
- },
198
- type: 'number',
199
- slotProps: {
200
- htmlInput: {
201
- step: 'any'
202
- }
203
- },
204
- fullWidth: true,
205
- size: size
206
- })
207
- ]);
208
- } else if (condition.kind === 'Regex') {
209
- return _react.default.createElement(_material.TextField, {
210
- label: 'Regular Expression',
211
- placeholder: 'JavaScript regular expression',
212
- value: condition.spec?.expr ?? '',
213
- onChange: (e)=>onChange({
214
- ...condition,
215
- spec: {
216
- expr: e.target.value
217
- }
218
- }),
219
- fullWidth: true,
220
- size: size
221
- });
222
- } else if (condition.kind === 'Misc') {
223
- const options = [
224
- {
225
- value: 'empty',
226
- label: 'Empty',
227
- caption: 'Matches empty string'
228
- },
229
- {
230
- value: 'null',
231
- label: 'Null',
232
- caption: 'Matches null or undefined'
233
- },
234
- {
235
- value: 'NaN',
236
- label: 'NaN',
237
- caption: 'Matches Not a Number value'
238
- },
239
- {
240
- value: 'true',
241
- label: 'True',
242
- caption: 'Matches true boolean'
243
- },
244
- {
245
- value: 'false',
246
- label: 'False',
247
- caption: 'Matches false boolean'
248
- }
249
- ];
250
- return _react.default.createElement(_material.TextField, {
251
- select: true,
252
- label: 'Value',
253
- value: condition.spec?.value ?? '',
254
- onChange: (e)=>onChange({
255
- ...condition,
256
- spec: {
257
- value: e.target.value
258
- }
259
- }),
260
- fullWidth: true,
261
- size: size
262
- }, options.map((option)=>_react.default.createElement(_material.MenuItem, {
263
- key: option.value,
264
- value: option.value
265
- }, _react.default.createElement(_material.Stack, {
266
- key: 'stack'
267
- }, [
268
- _react.default.createElement(_material.Typography, {
269
- key: 'title'
270
- }, option.label),
271
- _react.default.createElement(_material.Typography, {
272
- key: 'caption',
273
- variant: 'caption'
274
- }, option.caption)
275
- ]))));
276
- }
277
- return null;
278
- }
@@ -1,19 +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
- require("@testing-library/jest-dom");
18
- // Always mock e-charts during tests since we don't have a proper canvas in jsdom
19
- jest.mock('echarts/core');
@@ -1,84 +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
- function _export(target, all) {
18
- for(var name in all)Object.defineProperty(target, name, {
19
- enumerable: true,
20
- get: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get buildRawTableData () {
25
- return buildRawTableData;
26
- },
27
- get getTablePanelQueryMode () {
28
- return getTablePanelQueryMode;
29
- }
30
- });
31
- function getTablePanelQueryMode(spec) {
32
- return (spec.columnSettings ?? []).some((c)=>c.plugin) ? 'range' : 'instant';
33
- }
34
- function buildRawTableData(queryResults, spec, options = {}) {
35
- const { forExport = false } = options;
36
- const queryMode = getTablePanelQueryMode(spec);
37
- return queryResults.flatMap((data, queryIndex)=>(data.data?.series ?? []).map((ts)=>({
38
- data,
39
- ts,
40
- queryIndex
41
- }))).map(({ data, ts, queryIndex })=>{
42
- // Pick the last (most recent) data point. For range responses the last
43
- // value covers the window ending at the selected time range's end.
44
- const lastPoint = ts.values[ts.values.length - 1];
45
- if (lastPoint === undefined) {
46
- return {
47
- ...ts.labels
48
- };
49
- }
50
- // If there are multiple queries, add query index to value key and label keys to avoid conflicts
51
- const valueColumnName = queryResults.length === 1 ? 'value' : `value #${queryIndex + 1}`;
52
- const labels = queryResults.length === 1 ? ts.labels : Object.entries(ts.labels ?? {}).reduce((acc, [key, value])=>{
53
- if (key) acc[`${key} #${queryIndex + 1}`] = value;
54
- return acc;
55
- }, {});
56
- // For export: always use raw scalar values
57
- // For rendering: plugin columns get embedded PanelData objects
58
- let columnValue;
59
- if (forExport) {
60
- columnValue = lastPoint[1];
61
- } else {
62
- const hasPlugin = (spec.columnSettings ?? []).find((x)=>x.name === valueColumnName)?.plugin;
63
- columnValue = hasPlugin ? {
64
- ...data,
65
- data: {
66
- ...data.data,
67
- series: data.data.series.filter((s)=>s === ts)
68
- }
69
- } : lastPoint[1];
70
- }
71
- if (queryMode === 'instant') {
72
- return {
73
- timestamp: lastPoint[0],
74
- [valueColumnName]: columnValue,
75
- ...labels
76
- };
77
- } else {
78
- return {
79
- [valueColumnName]: columnValue,
80
- ...labels
81
- };
82
- }
83
- });
84
- }