@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,845 +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 TablePanel () {
25
- return TablePanel;
26
- },
27
- get getTablePanelQueryOptions () {
28
- return getTablePanelQueryOptions;
29
- }
30
- });
31
- const _jsxruntime = require("react/jsx-runtime");
32
- const _material = require("@mui/material");
33
- const _components = require("@perses-dev/components");
34
- const _dashboards = require("@perses-dev/dashboards");
35
- const _pluginsystem = require("@perses-dev/plugin-system");
36
- const _react = require("react");
37
- const _models = require("../models");
38
- const _tabledatautils = require("../table-data-utils");
39
- const _EmbeddedPanel = require("./EmbeddedPanel");
40
- function parseNumericCellValue(value) {
41
- if (typeof value === 'number' && Number.isFinite(value)) {
42
- return value;
43
- }
44
- if (typeof value === 'string') {
45
- const parsed = Number(value);
46
- if (Number.isFinite(parsed)) {
47
- return parsed;
48
- }
49
- }
50
- return undefined;
51
- }
52
- function isPanelData(value) {
53
- if (typeof value !== 'object' || value === null) {
54
- return false;
55
- }
56
- const candidate = value;
57
- return candidate.definition !== undefined && candidate.data !== undefined;
58
- }
59
- function createSyntheticPanelData(value, columnName) {
60
- const numericValue = parseNumericCellValue(value);
61
- if (numericValue === undefined) {
62
- return undefined;
63
- }
64
- const now = Date.now();
65
- return {
66
- definition: {
67
- kind: 'TimeSeriesQuery',
68
- spec: {
69
- plugin: {
70
- kind: 'PrometheusTimeSeriesQuery',
71
- spec: {
72
- query: ''
73
- }
74
- }
75
- }
76
- },
77
- data: {
78
- timeRange: {
79
- start: new Date(now),
80
- end: new Date(now)
81
- },
82
- stepMs: 1,
83
- series: [
84
- {
85
- name: columnName,
86
- values: [
87
- [
88
- now,
89
- numericValue
90
- ]
91
- ],
92
- labels: {}
93
- }
94
- ]
95
- }
96
- };
97
- }
98
- function getGaugeNumericValue(value) {
99
- if (isPanelData(value)) {
100
- const series = value.data?.series;
101
- const firstSeries = series?.[0];
102
- if (!firstSeries?.values?.length) {
103
- return undefined;
104
- }
105
- const calc = _pluginsystem.CalculationsMap['last-number'];
106
- if (typeof calc !== 'function') {
107
- return undefined;
108
- }
109
- const calculatedValue = calc(firstSeries.values);
110
- return typeof calculatedValue === 'number' ? calculatedValue : undefined;
111
- }
112
- return parseNumericCellValue(value);
113
- }
114
- function InlineGaugeCellWithRange({ value, range, fillColor, format }) {
115
- if (value === undefined) {
116
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {});
117
- }
118
- let percent = 0;
119
- if (range !== undefined) {
120
- if (range.max === range.min) {
121
- percent = 100;
122
- } else {
123
- percent = (value - range.min) / (range.max - range.min) * 100;
124
- }
125
- }
126
- percent = Math.max(0, Math.min(100, percent));
127
- const trackColor = 'rgba(127,127,127,0.20)';
128
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Box, {
129
- sx: {
130
- display: 'flex',
131
- alignItems: 'center',
132
- width: '100%',
133
- gap: 1
134
- },
135
- children: [
136
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
137
- sx: {
138
- flexGrow: 1,
139
- borderRadius: 1,
140
- backgroundColor: trackColor,
141
- height: 24,
142
- overflow: 'hidden'
143
- },
144
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
145
- sx: {
146
- width: `${percent}%`,
147
- height: '100%',
148
- backgroundColor: fillColor ?? 'success.main',
149
- borderRadius: 1
150
- }
151
- })
152
- }),
153
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
154
- variant: "body2",
155
- sx: {
156
- minWidth: 52,
157
- textAlign: 'right'
158
- },
159
- children: format ? (0, _components.formatValue)(value, format) : value.toFixed(2)
160
- })
161
- ]
162
- });
163
- }
164
- function resolveGaugeFillColor(value, globalCellSettings, columnCellSettings) {
165
- let cellConfig = (0, _models.evaluateConditionalFormatting)(value, globalCellSettings);
166
- if (columnCellSettings?.length) {
167
- const columnCellConfig = (0, _models.evaluateConditionalFormatting)(value, columnCellSettings);
168
- if (columnCellConfig) {
169
- cellConfig = columnCellConfig;
170
- }
171
- }
172
- return cellConfig?.backgroundColor ?? cellConfig?.textColor;
173
- }
174
- function generateCellContentConfig(column, gaugeRange, globalCellSettings = []) {
175
- const plugin = column.plugin;
176
- if (plugin !== undefined) {
177
- return {
178
- cell: (ctx)=>{
179
- const cellValue = ctx.getValue();
180
- if (plugin.kind === 'GaugeChart') {
181
- const gaugeValue = getGaugeNumericValue(cellValue);
182
- const gaugeFillColor = resolveGaugeFillColor(gaugeValue, globalCellSettings, column.cellSettings);
183
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(InlineGaugeCellWithRange, {
184
- value: gaugeValue,
185
- range: gaugeRange,
186
- fillColor: gaugeFillColor,
187
- format: plugin.spec?.format ?? column.format
188
- });
189
- }
190
- const panelData = isPanelData(cellValue) ? cellValue : createSyntheticPanelData(cellValue, column.name);
191
- if (!panelData) return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {});
192
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_EmbeddedPanel.EmbeddedPanel, {
193
- kind: plugin.kind,
194
- spec: plugin.spec,
195
- queryResults: [
196
- panelData
197
- ]
198
- });
199
- },
200
- cellDescription: column.cellDescription ? ()=>`${column.cellDescription}` : ()=>''
201
- };
202
- }
203
- return {
204
- cell: (ctx)=>{
205
- const cellValue = ctx.getValue();
206
- return typeof cellValue === 'number' && column.format ? (0, _components.formatValue)(cellValue, column.format) : cellValue;
207
- },
208
- cellDescription: column.cellDescription ? ()=>`${column.cellDescription}` : undefined
209
- };
210
- }
211
- function ColumnFilterDropdown({ allValues, selectedValues, onFilterChange, theme }) {
212
- const [searchTerm, setSearchTerm] = (0, _react.useState)('');
213
- const values = [
214
- ...new Set(allValues)
215
- ].filter((v)=>v !== null).sort();
216
- const filteredValues = searchTerm ? values.filter((v)=>String(v).toLowerCase().includes(searchTerm.toLowerCase())) : values;
217
- if (values.length === 0) {
218
- return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
219
- "data-filter-dropdown": true,
220
- style: {
221
- width: 200,
222
- padding: 10,
223
- backgroundColor: theme.palette.background.paper,
224
- border: `1px solid ${theme.palette.divider}`,
225
- borderRadius: 4,
226
- boxShadow: theme.shadows[4]
227
- },
228
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
229
- style: {
230
- color: theme.palette.text.secondary,
231
- fontSize: 14
232
- },
233
- children: "No values found"
234
- })
235
- });
236
- }
237
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
238
- "data-filter-dropdown": true,
239
- style: {
240
- width: 200,
241
- padding: 10,
242
- backgroundColor: theme.palette.background.paper,
243
- border: `1px solid ${theme.palette.divider}`,
244
- borderRadius: 4,
245
- boxShadow: theme.shadows[4],
246
- maxHeight: 250,
247
- overflowY: 'auto'
248
- },
249
- children: [
250
- /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
251
- type: "text",
252
- placeholder: "Search...",
253
- value: searchTerm,
254
- onChange: (e)=>setSearchTerm(e.target.value),
255
- style: {
256
- width: '100%',
257
- padding: '6px 8px',
258
- marginBottom: 8,
259
- fontSize: 13,
260
- border: `1px solid ${theme.palette.divider}`,
261
- borderRadius: 4,
262
- backgroundColor: theme.palette.background.default,
263
- color: theme.palette.text.primary,
264
- boxSizing: 'border-box'
265
- }
266
- }),
267
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
268
- style: {
269
- marginBottom: 8,
270
- fontSize: 14,
271
- fontWeight: 'bold'
272
- },
273
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("label", {
274
- style: {
275
- display: 'flex',
276
- alignItems: 'center',
277
- cursor: 'pointer'
278
- },
279
- children: [
280
- /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
281
- type: "checkbox",
282
- checked: selectedValues.length === values.length && values.length > 0,
283
- onChange: (e)=>onFilterChange(e.target.checked ? values.map((v)=>v.original) : []),
284
- style: {
285
- marginRight: 8
286
- }
287
- }),
288
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("span", {
289
- style: {
290
- color: theme.palette.text.primary
291
- },
292
- children: [
293
- "Select All (",
294
- values.length,
295
- ")"
296
- ]
297
- })
298
- ]
299
- })
300
- }),
301
- /*#__PURE__*/ (0, _jsxruntime.jsx)("hr", {
302
- style: {
303
- margin: '8px 0',
304
- border: 'none',
305
- borderTop: `1px solid ${theme.palette.divider}`
306
- }
307
- }),
308
- filteredValues.map((value, index)=>/*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
309
- style: {
310
- marginBottom: 4
311
- },
312
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("label", {
313
- style: {
314
- display: 'flex',
315
- alignItems: 'center',
316
- cursor: 'pointer',
317
- padding: '2px 0',
318
- borderRadius: 2
319
- },
320
- onMouseEnter: (e)=>{
321
- e.currentTarget.style.backgroundColor = theme.palette.action.hover;
322
- },
323
- onMouseLeave: (e)=>{
324
- e.currentTarget.style.backgroundColor = 'transparent';
325
- },
326
- children: [
327
- /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
328
- type: "checkbox",
329
- checked: selectedValues.includes(value.original),
330
- onChange: (e)=>{
331
- if (e.target.checked) {
332
- onFilterChange([
333
- ...selectedValues,
334
- value.original
335
- ]);
336
- } else {
337
- onFilterChange(selectedValues.filter((v)=>v !== value.original));
338
- }
339
- },
340
- style: {
341
- marginRight: 8
342
- }
343
- }),
344
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
345
- style: {
346
- fontSize: 14,
347
- color: theme.palette.text.primary
348
- },
349
- children: value === null || value === undefined || value.formatted === '' ? '(empty)' : String(value.formatted)
350
- })
351
- ]
352
- })
353
- }, `value-${index}`))
354
- ]
355
- });
356
- }
357
- /*
358
- * Generate column config from column definitions, if a column has multiple definitions, the first one will be used.
359
- * If column is hidden, return undefined.
360
- * If column do not have a definition, return a default column config.
361
- */ function generateColumnConfig(name, columnSettings, allVariables, gaugeRangeByColumn, globalCellSettings = []) {
362
- for (const column of columnSettings){
363
- if (column.name === name) {
364
- if (column.hide) {
365
- return undefined;
366
- }
367
- const { name, header, headerDescription, enableSorting, width, align, dataLink } = column;
368
- const modifiedDataLink = dataLink ? {
369
- ...dataLink,
370
- url: (0, _pluginsystem.replaceVariablesInString)(dataLink.url, allVariables)
371
- } : undefined;
372
- return {
373
- accessorKey: name,
374
- header: header ?? name,
375
- headerDescription,
376
- enableSorting,
377
- width,
378
- align,
379
- dataLink: modifiedDataLink,
380
- ...generateCellContentConfig(column, gaugeRangeByColumn[name], globalCellSettings)
381
- };
382
- }
383
- }
384
- return {
385
- accessorKey: name,
386
- header: name
387
- };
388
- }
389
- function getTablePanelQueryOptions(spec) {
390
- // if any cell renders a panel plugin, perform a range query instead of an instant query
391
- return {
392
- mode: (0, _tabledatautils.getTablePanelQueryMode)(spec)
393
- };
394
- }
395
- function TablePanel({ contentDimensions, spec, queryResults }) {
396
- const theme = (0, _material.useTheme)();
397
- const allVariables = (0, _pluginsystem.useAllVariableValues)();
398
- const selectionEnabled = spec.selection?.enabled ?? false;
399
- const { selectionMap, setSelection, clearSelection } = (0, _components.useSelection)();
400
- const itemActionsConfig = spec.actions ? spec.actions : undefined;
401
- const itemActionsListConfig = itemActionsConfig?.enabled && itemActionsConfig.displayWithItem ? itemActionsConfig.actionsList : [];
402
- const { getItemActionButtons, confirmDialog, actionButtons } = (0, _dashboards.useSelectionItemActions)({
403
- actions: itemActionsListConfig,
404
- variableState: allVariables
405
- });
406
- const filteredDataRef = (0, _react.useRef)([]);
407
- // Convert selectionMap to TanStack's RowSelectionState format
408
- const rowSelection = (0, _react.useMemo)(()=>{
409
- const result = {};
410
- selectionMap.forEach((_, id)=>{
411
- result[id] = true;
412
- });
413
- return result;
414
- }, [
415
- selectionMap
416
- ]);
417
- const handleRowSelectionChange = (0, _react.useCallback)((newRowSelection)=>{
418
- const newSelection = [];
419
- for (const [id, isSelected] of Object.entries(newRowSelection)){
420
- if (isSelected) {
421
- const index = parseInt(id, 10);
422
- if (filteredDataRef.current[index] !== undefined) {
423
- newSelection.push({
424
- id,
425
- item: filteredDataRef.current[index]
426
- });
427
- }
428
- }
429
- }
430
- if (newSelection.length === 0) {
431
- clearSelection();
432
- } else {
433
- setSelection(newSelection);
434
- }
435
- }, [
436
- setSelection,
437
- clearSelection
438
- ]);
439
- // TODO: handle other query types
440
- const rawData = (0, _react.useMemo)(()=>{
441
- // Transform query results to a tabular format using shared utility
442
- return (0, _tabledatautils.buildRawTableData)(queryResults, spec);
443
- }, [
444
- queryResults,
445
- spec
446
- ]);
447
- // Transform will be applied by their orders on the original data
448
- const data = (0, _react.useMemo)(()=>(0, _components.transformData)(rawData, spec.transforms ?? []), [
449
- rawData,
450
- spec.transforms
451
- ]);
452
- const keys = (0, _react.useMemo)(()=>{
453
- const result = [];
454
- for (const entry of data){
455
- for (const key of Object.keys(entry)){
456
- if (!result.includes(key)) {
457
- result.push(key);
458
- }
459
- }
460
- }
461
- // Include column names from columnSettings so that columns with no data
462
- // are still extended with undefined for cellSettings evaluation (e.g. N/A for null)
463
- for (const col of spec.columnSettings ?? []){
464
- if (!result.includes(col.name)) {
465
- result.push(col.name);
466
- }
467
- }
468
- return result;
469
- }, [
470
- data,
471
- spec.columnSettings
472
- ]);
473
- const columnsFormat = (0, _react.useMemo)(()=>{
474
- const columnsFormat = {};
475
- const settings = spec?.columnSettings;
476
- if (settings) {
477
- for(let i = 0; i < settings.length; i++){
478
- const { name, format } = settings[i] || {};
479
- if (name && format) {
480
- columnsFormat[name] = format;
481
- }
482
- }
483
- }
484
- return columnsFormat;
485
- }, [
486
- spec
487
- ]);
488
- const columnUniqueValues = (0, _react.useMemo)(()=>{
489
- const uniqueValues = {};
490
- for (const key of keys){
491
- const formatOption = columnsFormat?.[key];
492
- uniqueValues[key] = [];
493
- const usedValues = new Map();
494
- for (const row of data){
495
- const val = row[key];
496
- if (val === '' || val === null || val === undefined) {
497
- continue;
498
- }
499
- if (usedValues.get(String(val))) {
500
- continue;
501
- }
502
- if (typeof val === 'string' || typeof val === 'number') {
503
- uniqueValues[key].push({
504
- original: val,
505
- formatted: formatOption && typeof val === 'number' ? (0, _components.formatValue)(val, formatOption) : val
506
- });
507
- usedValues.set(String(val), true);
508
- }
509
- }
510
- }
511
- return uniqueValues;
512
- }, [
513
- data,
514
- keys,
515
- columnsFormat
516
- ]);
517
- const gaugeRangeByColumn = (0, _react.useMemo)(()=>{
518
- const result = {};
519
- for (const key of keys){
520
- let min = Number.POSITIVE_INFINITY;
521
- let max = Number.NEGATIVE_INFINITY;
522
- for (const row of data){
523
- const numericValue = getGaugeNumericValue(row[key]);
524
- if (numericValue === undefined) {
525
- continue;
526
- }
527
- min = Math.min(min, numericValue);
528
- max = Math.max(max, numericValue);
529
- }
530
- if (min !== Number.POSITIVE_INFINITY && max !== Number.NEGATIVE_INFINITY) {
531
- result[key] = {
532
- min,
533
- max
534
- };
535
- }
536
- }
537
- return result;
538
- }, [
539
- data,
540
- keys
541
- ]);
542
- // Generate columns and map each column accessor to its settings index and data key
543
- const columns = (0, _react.useMemo)(()=>{
544
- const columns = [];
545
- const customizedColumns = new Set();
546
- // Process columnSettings if they exist
547
- for (const columnSetting of spec.columnSettings ?? []){
548
- if (customizedColumns.has(columnSetting.name)) continue; // Skip duplicates
549
- const columnConfig = generateColumnConfig(columnSetting.name, spec.columnSettings ?? [], allVariables, gaugeRangeByColumn, spec.cellSettings ?? []);
550
- if (columnConfig !== undefined) {
551
- columns.push(columnConfig);
552
- customizedColumns.add(columnSetting.name);
553
- }
554
- }
555
- // Add remaining columns if defaultColumnHidden is false
556
- if (!spec.defaultColumnHidden) {
557
- for (const key of keys){
558
- if (!customizedColumns.has(key)) {
559
- const columnConfig = generateColumnConfig(key, spec.columnSettings ?? [], allVariables, gaugeRangeByColumn, spec.cellSettings ?? []);
560
- if (columnConfig !== undefined) {
561
- columns.push(columnConfig);
562
- }
563
- }
564
- }
565
- }
566
- return columns;
567
- }, [
568
- keys,
569
- spec.columnSettings,
570
- spec.defaultColumnHidden,
571
- allVariables,
572
- gaugeRangeByColumn,
573
- spec.cellSettings
574
- ]);
575
- // Filtering state — declared before cellConfigs so filteredData is available for cell config evaluation
576
- const [columnFilters, setColumnFilters] = (0, _react.useState)([]);
577
- // filter data based on the current filters
578
- const filteredData = (0, _react.useMemo)(()=>{
579
- if (!spec.enableFiltering || columnFilters.length === 0) {
580
- return data;
581
- }
582
- return data.filter((row)=>{
583
- return columnFilters.every((filter)=>{
584
- const value = row[filter.id];
585
- const filterValues = filter.value;
586
- if (!filterValues || filterValues.length === 0) return true;
587
- return filterValues.includes(value);
588
- });
589
- });
590
- }, [
591
- data,
592
- columnFilters,
593
- spec.enableFiltering
594
- ]);
595
- // Generate cell settings that will be used by the table to render cells (text color, background color, ...)
596
- const cellConfigs = (0, _react.useMemo)(()=>{
597
- // If there are no cell settings globally or per column, return an empty object
598
- if (spec.cellSettings === undefined && !spec.columnSettings?.some((col)=>col.cellSettings !== undefined)) {
599
- return {};
600
- }
601
- const result = {};
602
- let index = 0;
603
- for (const row of filteredData){
604
- // Transforming key to object to extend the row with undefined values if the key is not present
605
- // for checking the cell config "Misc" condition with "null"
606
- const keysAsObj = keys.reduce((acc, key)=>{
607
- acc[key] = undefined;
608
- return acc;
609
- }, {});
610
- const extendRow = {
611
- ...keysAsObj,
612
- ...row
613
- };
614
- // Generate cellConfigs for each column (including duplicates with different headers)
615
- for (const [key, value] of Object.entries(extendRow)){
616
- // First, try to get cell config from global cell settings
617
- let cellConfig = (0, _models.evaluateConditionalFormatting)(value, spec.cellSettings ?? []);
618
- // Then, try to get cell config from column-specific cell settings
619
- const columnSetting = spec.columnSettings?.find((col)=>col.name === key);
620
- if (columnSetting?.cellSettings?.length) {
621
- const columnCellConfig = (0, _models.evaluateConditionalFormatting)(value, columnSetting.cellSettings);
622
- // Column-specific settings take precedence over global settings
623
- if (columnCellConfig) {
624
- cellConfig = columnCellConfig;
625
- }
626
- }
627
- if (cellConfig) {
628
- result[`${index}_${key}`] = cellConfig;
629
- }
630
- }
631
- index++;
632
- }
633
- return result;
634
- }, [
635
- filteredData,
636
- keys,
637
- spec.cellSettings,
638
- spec.columnSettings
639
- ]);
640
- function generateDefaultSortingState() {
641
- return spec.columnSettings?.filter((column)=>column.sort !== undefined).map((column)=>{
642
- return {
643
- id: column.name,
644
- desc: column.sort === 'desc'
645
- };
646
- }) ?? [];
647
- }
648
- const [sorting, setSorting] = (0, _react.useState)(generateDefaultSortingState());
649
- const [filterAnchorEl, setFilterAnchorEl] = (0, _react.useState)({});
650
- const [openFilterColumn, setOpenFilterColumn] = (0, _react.useState)(null);
651
- // get selected values for a column
652
- const getSelectedFilterValues = (columnId)=>{
653
- const filter = columnFilters.find((f)=>f.id === columnId);
654
- return filter ? filter.value : [];
655
- };
656
- // update column filter
657
- const updateColumnFilter = (columnId, values)=>{
658
- const newFilters = columnFilters.filter((f)=>f.id !== columnId);
659
- if (values.length > 0) {
660
- newFilters.push({
661
- id: columnId,
662
- value: values
663
- });
664
- }
665
- setColumnFilters(newFilters);
666
- };
667
- // Handle filter clicks
668
- const handleFilterClick = (event, columnId)=>{
669
- event.preventDefault();
670
- event.stopPropagation();
671
- setFilterAnchorEl({
672
- ...filterAnchorEl,
673
- [columnId]: event.currentTarget
674
- });
675
- setOpenFilterColumn(columnId);
676
- };
677
- const handleFilterClose = ()=>{
678
- setFilterAnchorEl({});
679
- setOpenFilterColumn(null);
680
- };
681
- // Close filter when clicking outside
682
- (0, _react.useEffect)(()=>{
683
- if (!openFilterColumn) return;
684
- const handleClick = (e)=>{
685
- const target = e.target;
686
- if (!target.closest('[data-filter-dropdown]') && !target.closest('button')) {
687
- handleFilterClose();
688
- }
689
- };
690
- const timer = setTimeout(()=>{
691
- document.addEventListener('click', handleClick);
692
- }, 100);
693
- return ()=>{
694
- clearTimeout(timer);
695
- document.removeEventListener('click', handleClick);
696
- };
697
- }, [
698
- openFilterColumn
699
- ]);
700
- // Keep ref in sync with filtered data for use in selection handler
701
- filteredDataRef.current = filteredData;
702
- const [pagination, setPagination] = (0, _react.useState)(spec.pagination ? {
703
- pageIndex: 0,
704
- pageSize: 10
705
- } : undefined);
706
- (0, _react.useEffect)(()=>{
707
- // If the pagination setting changes from no pagination to pagination, but the pagination state is undefined, update the pagination state
708
- if (spec.pagination && !pagination) {
709
- setPagination({
710
- pageIndex: 0,
711
- pageSize: 10
712
- });
713
- } else if (!spec.pagination && pagination) {
714
- setPagination(undefined);
715
- }
716
- }, [
717
- spec.pagination,
718
- pagination
719
- ]);
720
- if (contentDimensions === undefined) {
721
- return null;
722
- }
723
- if (!data?.length) {
724
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
725
- sx: {
726
- display: 'flex',
727
- justifyContent: 'center',
728
- alignItems: 'center',
729
- height: '100%'
730
- },
731
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Typography, {
732
- children: "No data"
733
- })
734
- });
735
- }
736
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
737
- children: [
738
- confirmDialog,
739
- spec.enableFiltering && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
740
- style: {
741
- display: 'flex',
742
- background: theme.palette.background.default,
743
- borderBottom: `1px solid ${theme.palette.divider}`,
744
- width: contentDimensions.width,
745
- boxSizing: 'border-box'
746
- },
747
- children: columns.map((column, idx)=>{
748
- const filters = getSelectedFilterValues(column.accessorKey);
749
- const columnWidth = column.width || spec.defaultColumnWidth;
750
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
751
- style: {
752
- padding: '8px',
753
- borderRight: idx < columns.length - 1 ? `1px solid ${theme.palette.divider}` : 'none',
754
- width: columnWidth,
755
- minWidth: columnWidth,
756
- maxWidth: columnWidth,
757
- display: 'flex',
758
- alignItems: 'center',
759
- position: 'relative',
760
- boxSizing: 'border-box',
761
- flex: typeof columnWidth === 'number' ? 'none' : '1 1 auto'
762
- },
763
- children: [
764
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
765
- style: {
766
- marginRight: 8,
767
- fontSize: '12px',
768
- color: theme.palette.text.secondary,
769
- flex: 1,
770
- overflow: 'hidden',
771
- textOverflow: 'ellipsis',
772
- whiteSpace: 'nowrap'
773
- },
774
- children: filters.length ? `${filters.length} items` : 'All'
775
- }),
776
- /*#__PURE__*/ (0, _jsxruntime.jsx)("button", {
777
- onClick: (e)=>{
778
- handleFilterClick(e, column.accessorKey);
779
- },
780
- style: {
781
- border: `1px solid ${theme.palette.divider}`,
782
- background: theme.palette.background.paper,
783
- cursor: 'pointer',
784
- fontSize: '12px',
785
- color: filters.length ? theme.palette.primary.main : theme.palette.text.secondary,
786
- padding: '4px 8px',
787
- borderRadius: '4px',
788
- minWidth: '20px',
789
- height: '24px',
790
- flexShrink: 0,
791
- transition: 'all 0.2s ease'
792
- },
793
- onMouseEnter: (e)=>{
794
- e.currentTarget.style.background = theme.palette.action.hover;
795
- },
796
- onMouseLeave: (e)=>{
797
- e.currentTarget.style.background = theme.palette.background.paper;
798
- },
799
- type: "button",
800
- children: "▼"
801
- }),
802
- openFilterColumn === column.accessorKey && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
803
- style: {
804
- position: 'absolute',
805
- top: '100%',
806
- left: 0,
807
- zIndex: 1000,
808
- marginTop: 4
809
- },
810
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(ColumnFilterDropdown, {
811
- allValues: columnUniqueValues[column.accessorKey] || [],
812
- selectedValues: filters,
813
- onFilterChange: (values)=>updateColumnFilter(column.accessorKey, values),
814
- theme: theme
815
- })
816
- })
817
- ]
818
- }, `filter-${idx}`);
819
- })
820
- }),
821
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Table, {
822
- data: filteredData,
823
- columns: columns,
824
- cellConfigs: cellConfigs,
825
- height: spec.enableFiltering ? contentDimensions.height - 40 : contentDimensions.height,
826
- width: contentDimensions.width,
827
- density: spec.density,
828
- defaultColumnWidth: spec.defaultColumnWidth,
829
- defaultColumnHeight: spec.defaultColumnHeight,
830
- sorting: sorting,
831
- onSortingChange: setSorting,
832
- pagination: pagination,
833
- onPaginationChange: setPagination,
834
- checkboxSelection: selectionEnabled,
835
- rowSelection: rowSelection,
836
- onRowSelectionChange: handleRowSelectionChange,
837
- getItemActions: ({ id, data })=>getItemActionButtons({
838
- id,
839
- data: data
840
- }),
841
- hasItemActions: actionButtons && actionButtons.length > 0
842
- })
843
- ]
844
- });
845
- }