@perses-dev/table-plugin 0.11.0-rc.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__mf/js/{Table.7c94517d.js → Table.2fc0ce5e.js} +3 -3
- package/__mf/js/async/1117.b21b0ae4.js +2 -0
- package/__mf/js/async/{2473.2c502914.js → 1432.acd0ad59.js} +1 -1
- package/__mf/js/async/272.3bc7825c.js +1 -0
- package/__mf/js/async/392.49e51fc5.js +2 -0
- package/__mf/js/async/4510.a0a1dd48.js +7 -0
- package/__mf/js/async/54.467c4f98.js +22 -0
- package/__mf/js/async/6811.4e18bc66.js +38 -0
- package/__mf/js/async/9010.fd805430.js +1 -0
- package/__mf/js/async/{1432.4dcbe7e3.js → 9051.e3054e02.js} +1 -1
- package/__mf/js/async/__federation_expose_Table.b3466cfe.js +1 -0
- package/__mf/js/async/lib-router.2e1dec85.js +2 -0
- package/__mf/js/async/{lib-router.8fd59130.js.LICENSE.txt → lib-router.2e1dec85.js.LICENSE.txt} +3 -3
- package/__mf/js/{main.1250232e.js → main.83aeba98.js} +3 -3
- package/lib/Table.d.ts +1 -1
- package/lib/Table.d.ts.map +1 -1
- package/lib/Table.js +7 -2
- package/lib/Table.js.map +1 -1
- package/lib/bootstrap.js +1 -1
- package/lib/bootstrap.js.map +1 -1
- package/lib/cjs/Table.js +7 -2
- package/lib/cjs/bootstrap.js +1 -1
- package/lib/cjs/components/CellsEditor/CellsEditor.js +1 -1
- package/lib/cjs/components/CellsEditor/index.js +1 -1
- package/lib/cjs/components/ColumnsEditor/ColumnEditor.js +1 -1
- package/lib/cjs/components/ColumnsEditor/ColumnEditorContainer.js +1 -1
- package/lib/cjs/components/ColumnsEditor/ColumnsEditor.js +1 -1
- package/lib/cjs/components/ColumnsEditor/DataLinkEditorDialog.js +1 -1
- package/lib/cjs/components/ColumnsEditor/index.js +1 -1
- package/lib/cjs/components/ConditionalPanel.js +12 -0
- package/lib/cjs/components/EmbeddedPanel.js +1 -1
- package/lib/cjs/components/TableCellsEditor.js +1 -1
- package/lib/cjs/components/TableColumnsEditor.js +1 -1
- package/lib/cjs/components/TableItemSelectionActionsEditor.js +44 -0
- package/lib/cjs/components/TablePanel.js +73 -10
- package/lib/cjs/components/TableSettingsEditor.js +1 -1
- package/lib/cjs/components/TableTransformsEditor.js +1 -1
- package/lib/cjs/components/index.js +2 -1
- package/lib/cjs/env.d.js +1 -1
- package/lib/cjs/getPluginModule.js +12 -0
- package/lib/cjs/index-federation.js +1 -1
- package/lib/cjs/index.js +12 -0
- package/lib/cjs/models/index.js +1 -1
- package/lib/cjs/models/model.js +1 -1
- package/lib/cjs/models/table-model.js +1 -1
- package/lib/cjs/setup-tests.js +1 -1
- package/lib/cjs/test/mock-query-results.js +1 -1
- package/lib/components/CellsEditor/CellsEditor.js +1 -1
- package/lib/components/CellsEditor/CellsEditor.js.map +1 -1
- package/lib/components/CellsEditor/index.js +1 -1
- package/lib/components/CellsEditor/index.js.map +1 -1
- package/lib/components/ColumnsEditor/ColumnEditor.js +1 -1
- package/lib/components/ColumnsEditor/ColumnEditor.js.map +1 -1
- package/lib/components/ColumnsEditor/ColumnEditorContainer.js +1 -1
- package/lib/components/ColumnsEditor/ColumnEditorContainer.js.map +1 -1
- package/lib/components/ColumnsEditor/ColumnsEditor.js +1 -1
- package/lib/components/ColumnsEditor/ColumnsEditor.js.map +1 -1
- package/lib/components/ColumnsEditor/DataLinkEditorDialog.js +1 -1
- package/lib/components/ColumnsEditor/DataLinkEditorDialog.js.map +1 -1
- package/lib/components/ColumnsEditor/index.js +1 -1
- package/lib/components/ColumnsEditor/index.js.map +1 -1
- package/lib/components/ConditionalPanel.d.ts.map +1 -1
- package/lib/components/ConditionalPanel.js +12 -0
- package/lib/components/ConditionalPanel.js.map +1 -1
- package/lib/components/EmbeddedPanel.js +1 -1
- package/lib/components/EmbeddedPanel.js.map +1 -1
- package/lib/components/TableCellsEditor.js +1 -1
- package/lib/components/TableCellsEditor.js.map +1 -1
- package/lib/components/TableColumnsEditor.js +1 -1
- package/lib/components/TableColumnsEditor.js.map +1 -1
- package/lib/components/TableItemSelectionActionsEditor.d.ts +4 -0
- package/lib/components/TableItemSelectionActionsEditor.d.ts.map +1 -0
- package/lib/components/TableItemSelectionActionsEditor.js +36 -0
- package/lib/components/TableItemSelectionActionsEditor.js.map +1 -0
- package/lib/components/TablePanel.d.ts +1 -1
- package/lib/components/TablePanel.d.ts.map +1 -1
- package/lib/components/TablePanel.js +75 -12
- package/lib/components/TablePanel.js.map +1 -1
- package/lib/components/TableSettingsEditor.js +1 -1
- package/lib/components/TableSettingsEditor.js.map +1 -1
- package/lib/components/TableTransformsEditor.js +1 -1
- package/lib/components/TableTransformsEditor.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.d.ts.map +1 -1
- package/lib/components/index.js +2 -1
- package/lib/components/index.js.map +1 -1
- package/lib/env.d.js +1 -1
- package/lib/env.d.js.map +1 -1
- package/lib/getPluginModule.d.ts.map +1 -1
- package/lib/getPluginModule.js +12 -0
- package/lib/getPluginModule.js.map +1 -1
- package/lib/index-federation.js +1 -1
- package/lib/index-federation.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -1
- package/lib/models/index.js +1 -1
- package/lib/models/index.js.map +1 -1
- package/lib/models/model.js +1 -1
- package/lib/models/model.js.map +1 -1
- package/lib/models/table-model.d.ts +3 -1
- package/lib/models/table-model.d.ts.map +1 -1
- package/lib/models/table-model.js +1 -1
- package/lib/models/table-model.js.map +1 -1
- package/lib/setup-tests.js +1 -1
- package/lib/setup-tests.js.map +1 -1
- package/lib/test/mock-query-results.js +1 -1
- package/lib/test/mock-query-results.js.map +1 -1
- package/mf-manifest.json +23 -23
- package/mf-stats.json +25 -25
- package/package.json +6 -5
- package/__mf/js/async/1117.87be49e9.js +0 -2
- package/__mf/js/async/1490.9d97e5d1.js +0 -22
- package/__mf/js/async/3827.1b39b042.js +0 -38
- package/__mf/js/async/3919.927efb3c.js +0 -7
- package/__mf/js/async/392.c2307fe5.js +0 -2
- package/__mf/js/async/5501.bc363348.js +0 -1
- package/__mf/js/async/8094.c02682f3.js +0 -1
- package/__mf/js/async/__federation_expose_Table.61be353a.js +0 -1
- package/__mf/js/async/lib-router.8fd59130.js +0 -2
- /package/__mf/js/async/{1117.87be49e9.js.LICENSE.txt → 1117.b21b0ae4.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{392.c2307fe5.js.LICENSE.txt → 392.49e51fc5.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{3919.927efb3c.js.LICENSE.txt → 4510.a0a1dd48.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{1490.9d97e5d1.js.LICENSE.txt → 54.467c4f98.js.LICENSE.txt} +0 -0
|
@@ -1,3 +1,15 @@
|
|
|
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.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
|
@@ -0,0 +1,44 @@
|
|
|
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, "TableItemSelectionActionsEditor", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function() {
|
|
20
|
+
return TableItemSelectionActionsEditor;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
25
|
+
function TableItemSelectionActionsEditor({ value, onChange }) {
|
|
26
|
+
function handleActionsChange(actions) {
|
|
27
|
+
onChange({
|
|
28
|
+
...value,
|
|
29
|
+
actions: actions
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function handleSelectionChange(selection) {
|
|
33
|
+
onChange({
|
|
34
|
+
...value,
|
|
35
|
+
selection: selection
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.ItemSelectionActionsEditor, {
|
|
39
|
+
actionOptions: value.actions,
|
|
40
|
+
onChangeActions: handleActionsChange,
|
|
41
|
+
selectionOptions: value.selection,
|
|
42
|
+
onChangeSelection: handleSelectionChange
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -29,10 +29,12 @@ _export(exports, {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const _jsxruntime = require("react/jsx-runtime");
|
|
32
|
+
const _material = require("@mui/material");
|
|
32
33
|
const _components = require("@perses-dev/components");
|
|
33
|
-
const _react = require("react");
|
|
34
34
|
const _core = require("@perses-dev/core");
|
|
35
|
-
const
|
|
35
|
+
const _dashboards = require("@perses-dev/dashboards");
|
|
36
|
+
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
37
|
+
const _react = require("react");
|
|
36
38
|
const _models = require("../models");
|
|
37
39
|
const _EmbeddedPanel = require("./EmbeddedPanel");
|
|
38
40
|
function generateCellContentConfig(column) {
|
|
@@ -192,13 +194,17 @@ function ColumnFilterDropdown({ allValues, selectedValues, onFilterChange, theme
|
|
|
192
194
|
* Generate column config from column definitions, if a column has multiple definitions, the first one will be used.
|
|
193
195
|
* If column is hidden, return undefined.
|
|
194
196
|
* If column do not have a definition, return a default column config.
|
|
195
|
-
*/ function generateColumnConfig(name, columnSettings) {
|
|
197
|
+
*/ function generateColumnConfig(name, columnSettings, allVariables) {
|
|
196
198
|
for (const column of columnSettings){
|
|
197
199
|
if (column.name === name) {
|
|
198
200
|
if (column.hide) {
|
|
199
201
|
return undefined;
|
|
200
202
|
}
|
|
201
203
|
const { name, header, headerDescription, enableSorting, width, align, dataLink } = column;
|
|
204
|
+
const modifiedDataLink = dataLink ? {
|
|
205
|
+
...dataLink,
|
|
206
|
+
url: (0, _pluginsystem.replaceVariablesInString)(dataLink.url, allVariables)
|
|
207
|
+
} : undefined;
|
|
202
208
|
return {
|
|
203
209
|
accessorKey: name,
|
|
204
210
|
header: header ?? name,
|
|
@@ -206,7 +212,7 @@ function ColumnFilterDropdown({ allValues, selectedValues, onFilterChange, theme
|
|
|
206
212
|
enableSorting,
|
|
207
213
|
width,
|
|
208
214
|
align,
|
|
209
|
-
dataLink,
|
|
215
|
+
dataLink: modifiedDataLink,
|
|
210
216
|
...generateCellContentConfig(column)
|
|
211
217
|
};
|
|
212
218
|
}
|
|
@@ -224,6 +230,48 @@ function getTablePanelQueryOptions(spec) {
|
|
|
224
230
|
}
|
|
225
231
|
function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
226
232
|
const theme = (0, _material.useTheme)();
|
|
233
|
+
const allVariables = (0, _pluginsystem.useAllVariableValues)();
|
|
234
|
+
const selectionEnabled = spec.selection?.enabled ?? false;
|
|
235
|
+
const { selectionMap, setSelection, clearSelection } = (0, _components.useSelection)();
|
|
236
|
+
const itemActionsConfig = spec.actions ? spec.actions : undefined;
|
|
237
|
+
const itemActionsListConfig = itemActionsConfig?.enabled && itemActionsConfig.displayWithItem ? itemActionsConfig.actionsList : [];
|
|
238
|
+
const { getItemActionButtons, confirmDialog, actionButtons } = (0, _dashboards.useSelectionItemActions)({
|
|
239
|
+
actions: itemActionsListConfig,
|
|
240
|
+
variableState: allVariables
|
|
241
|
+
});
|
|
242
|
+
const filteredDataRef = (0, _react.useRef)([]);
|
|
243
|
+
// Convert selectionMap to TanStack's RowSelectionState format
|
|
244
|
+
const rowSelection = (0, _react.useMemo)(()=>{
|
|
245
|
+
const result = {};
|
|
246
|
+
selectionMap.forEach((_, id)=>{
|
|
247
|
+
result[id] = true;
|
|
248
|
+
});
|
|
249
|
+
return result;
|
|
250
|
+
}, [
|
|
251
|
+
selectionMap
|
|
252
|
+
]);
|
|
253
|
+
const handleRowSelectionChange = (0, _react.useCallback)((newRowSelection)=>{
|
|
254
|
+
const newSelection = [];
|
|
255
|
+
for (const [id, isSelected] of Object.entries(newRowSelection)){
|
|
256
|
+
if (isSelected) {
|
|
257
|
+
const index = parseInt(id, 10);
|
|
258
|
+
if (filteredDataRef.current[index] !== undefined) {
|
|
259
|
+
newSelection.push({
|
|
260
|
+
id,
|
|
261
|
+
item: filteredDataRef.current[index]
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
if (newSelection.length === 0) {
|
|
267
|
+
clearSelection();
|
|
268
|
+
} else {
|
|
269
|
+
setSelection(newSelection);
|
|
270
|
+
}
|
|
271
|
+
}, [
|
|
272
|
+
setSelection,
|
|
273
|
+
clearSelection
|
|
274
|
+
]);
|
|
227
275
|
// TODO: handle other query types
|
|
228
276
|
const queryMode = getTablePanelQueryOptions(spec).mode;
|
|
229
277
|
const rawData = (0, _react.useMemo)(()=>{
|
|
@@ -274,7 +322,10 @@ function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
|
274
322
|
spec.columnSettings
|
|
275
323
|
]);
|
|
276
324
|
// Transform will be applied by their orders on the original data
|
|
277
|
-
const data = (0, _core.transformData)(rawData, spec.transforms ?? [])
|
|
325
|
+
const data = (0, _react.useMemo)(()=>(0, _core.transformData)(rawData, spec.transforms ?? []), [
|
|
326
|
+
rawData,
|
|
327
|
+
spec.transforms
|
|
328
|
+
]);
|
|
278
329
|
const keys = (0, _react.useMemo)(()=>{
|
|
279
330
|
const result = [];
|
|
280
331
|
for (const entry of data){
|
|
@@ -307,7 +358,7 @@ function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
|
307
358
|
// Process columnSettings if they exist
|
|
308
359
|
for (const columnSetting of spec.columnSettings ?? []){
|
|
309
360
|
if (customizedColumns.has(columnSetting.name)) continue; // Skip duplicates
|
|
310
|
-
const columnConfig = generateColumnConfig(columnSetting.name, spec.columnSettings ?? []);
|
|
361
|
+
const columnConfig = generateColumnConfig(columnSetting.name, spec.columnSettings ?? [], allVariables);
|
|
311
362
|
if (columnConfig !== undefined) {
|
|
312
363
|
columns.push(columnConfig);
|
|
313
364
|
customizedColumns.add(columnSetting.name);
|
|
@@ -317,7 +368,7 @@ function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
|
317
368
|
if (!spec.defaultColumnHidden) {
|
|
318
369
|
for (const key of keys){
|
|
319
370
|
if (!customizedColumns.has(key)) {
|
|
320
|
-
const columnConfig = generateColumnConfig(key, spec.columnSettings ?? []);
|
|
371
|
+
const columnConfig = generateColumnConfig(key, spec.columnSettings ?? [], allVariables);
|
|
321
372
|
if (columnConfig !== undefined) {
|
|
322
373
|
columns.push(columnConfig);
|
|
323
374
|
}
|
|
@@ -328,7 +379,8 @@ function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
|
328
379
|
}, [
|
|
329
380
|
keys,
|
|
330
381
|
spec.columnSettings,
|
|
331
|
-
spec.defaultColumnHidden
|
|
382
|
+
spec.defaultColumnHidden,
|
|
383
|
+
allVariables
|
|
332
384
|
]);
|
|
333
385
|
// Generate cell settings that will be used by the table to render cells (text color, background color, ...)
|
|
334
386
|
const cellConfigs = (0, _react.useMemo)(()=>{
|
|
@@ -460,6 +512,8 @@ function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
|
460
512
|
columnFilters,
|
|
461
513
|
spec.enableFiltering
|
|
462
514
|
]);
|
|
515
|
+
// Keep ref in sync with filtered data for use in selection handler
|
|
516
|
+
filteredDataRef.current = filteredData;
|
|
463
517
|
const [pagination, setPagination] = (0, _react.useState)(spec.pagination ? {
|
|
464
518
|
pageIndex: 0,
|
|
465
519
|
pageSize: 10
|
|
@@ -496,6 +550,7 @@ function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
|
496
550
|
}
|
|
497
551
|
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
498
552
|
children: [
|
|
553
|
+
confirmDialog,
|
|
499
554
|
spec.enableFiltering && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
|
|
500
555
|
style: {
|
|
501
556
|
display: 'flex',
|
|
@@ -590,7 +645,15 @@ function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
|
590
645
|
sorting: sorting,
|
|
591
646
|
onSortingChange: setSorting,
|
|
592
647
|
pagination: pagination,
|
|
593
|
-
onPaginationChange: setPagination
|
|
648
|
+
onPaginationChange: setPagination,
|
|
649
|
+
checkboxSelection: selectionEnabled,
|
|
650
|
+
rowSelection: rowSelection,
|
|
651
|
+
onRowSelectionChange: handleRowSelectionChange,
|
|
652
|
+
getItemActions: ({ id, data })=>getItemActionButtons({
|
|
653
|
+
id,
|
|
654
|
+
data: data
|
|
655
|
+
}),
|
|
656
|
+
hasItemActions: actionButtons && actionButtons.length > 0
|
|
594
657
|
})
|
|
595
658
|
]
|
|
596
659
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Copyright
|
|
1
|
+
// Copyright The Perses Authors
|
|
2
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
3
|
// you may not use this file except in compliance with the License.
|
|
4
4
|
// You may obtain a copy of the License at
|
|
@@ -19,6 +19,7 @@ _export_star(require("./ColumnsEditor"), exports);
|
|
|
19
19
|
_export_star(require("./EmbeddedPanel"), exports);
|
|
20
20
|
_export_star(require("./TableCellsEditor"), exports);
|
|
21
21
|
_export_star(require("./TableColumnsEditor"), exports);
|
|
22
|
+
_export_star(require("./TableItemSelectionActionsEditor"), exports);
|
|
22
23
|
_export_star(require("./TablePanel"), exports);
|
|
23
24
|
_export_star(require("./TableSettingsEditor"), exports);
|
|
24
25
|
_export_star(require("./TableTransformsEditor"), exports);
|
package/lib/cjs/env.d.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
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.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
|
@@ -40,7 +40,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
40
40
|
}
|
|
41
41
|
return newObj;
|
|
42
42
|
}
|
|
43
|
-
// Copyright
|
|
43
|
+
// Copyright The Perses Authors
|
|
44
44
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
45
45
|
// you may not use this file except in compliance with the License.
|
|
46
46
|
// You may obtain a copy of the License at
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
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.
|
|
1
13
|
"use strict";
|
|
2
14
|
Object.defineProperty(exports, "__esModule", {
|
|
3
15
|
value: true
|
package/lib/cjs/models/index.js
CHANGED
package/lib/cjs/models/model.js
CHANGED
package/lib/cjs/setup-tests.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/CellsEditor/CellsEditor.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/CellsEditor/CellsEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ReactElement } from 'react';\nimport { CellSettings } from '../../models';\nimport { ConditionalPanel } from '../ConditionalPanel';\n\nexport interface CellsEditorProps {\n cellSettings: CellSettings[];\n onChange: (cellOptions: CellSettings[]) => void;\n}\n\nexport function CellsEditor({ cellSettings, onChange }: CellsEditorProps): ReactElement {\n return (\n <ConditionalPanel\n cellSettings={cellSettings}\n onChange={(updatedCellSettings) => onChange(updatedCellSettings || [])}\n />\n );\n}\n"],"names":["ConditionalPanel","CellsEditor","cellSettings","onChange","updatedCellSettings"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAIjC,SAASA,gBAAgB,QAAQ,sBAAsB;AAOvD,OAAO,SAASC,YAAY,EAAEC,YAAY,EAAEC,QAAQ,EAAoB;IACtE,qBACE,KAACH;QACCE,cAAcA;QACdC,UAAU,CAACC,sBAAwBD,SAASC,uBAAuB,EAAE;;AAG3E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/CellsEditor/index.ts"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/CellsEditor/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './CellsEditor';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,gBAAgB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
5
5
|
// You may obtain a copy of the License at
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ColumnsEditor/ColumnEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Button, ButtonGroup, Stack, StackProps, Switch, TextField } from '@mui/material';\nimport { ReactElement, useState } from 'react';\nimport {\n AlignSelector,\n FormatControls,\n OptionsEditorColumn,\n OptionsEditorControl,\n OptionsEditorGrid,\n OptionsEditorGroup,\n SortSelectorButtons,\n} from '@perses-dev/components';\nimport { FormatOptions } from '@perses-dev/core';\nimport { PluginKindSelect } from '@perses-dev/plugin-system';\n\nimport { ColumnSettings } from '../../models';\nimport { ConditionalPanel } from '../ConditionalPanel';\nimport { DataLinkEditor } from './DataLinkEditorDialog';\n\nconst DEFAULT_FORMAT: FormatOptions = {\n unit: 'decimal',\n shortValues: true,\n};\n\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface ColumnEditorProps extends Omit<StackProps, OmittedMuiProps> {\n column: ColumnSettings;\n onChange: (column: ColumnSettings) => void;\n}\n\nexport function ColumnEditor({ column, onChange, ...others }: ColumnEditorProps): ReactElement {\n const [width, setWidth] = useState<number>(\n column.width === undefined || column.width === 'auto' ? 100 : column.width\n );\n\n return (\n <Stack {...others}>\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Column\">\n <OptionsEditorControl\n label=\"Name*\"\n control={\n <TextField\n value={column.name}\n onChange={(e) => onChange({ ...column, name: e.target.value })}\n required\n />\n }\n />\n <OptionsEditorControl\n label=\"Header\"\n control={\n <TextField\n value={column.header ?? ''}\n onChange={(e) => onChange({ ...column, header: e.target.value ? e.target.value : undefined })}\n />\n }\n />\n <OptionsEditorControl\n label=\"Header Tooltip\"\n control={\n <TextField\n value={column.headerDescription ?? ''}\n onChange={(e) =>\n onChange({ ...column, headerDescription: e.target.value ? e.target.value : undefined })\n }\n />\n }\n />\n <OptionsEditorControl\n label=\"Cell Tooltip\"\n control={\n <TextField\n value={column.cellDescription ?? ''}\n onChange={(e) =>\n onChange({ ...column, cellDescription: e.target.value ? e.target.value : undefined })\n }\n />\n }\n />\n <OptionsEditorControl\n label=\"Enable sorting\"\n control={\n <Switch\n checked={column.enableSorting ?? false}\n onChange={(e) => onChange({ ...column, enableSorting: e.target.checked })}\n />\n }\n />\n {column.enableSorting && (\n <OptionsEditorControl\n label=\"Default Sort\"\n control={\n <SortSelectorButtons\n size=\"medium\"\n value={column.sort}\n sx={{\n margin: 0.5,\n }}\n onChange={(sort) => onChange({ ...column, sort: sort })}\n />\n }\n />\n )}\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Visual\">\n <OptionsEditorControl\n label=\"Show column\"\n control={\n <Switch\n checked={!(column.hide ?? false)}\n onChange={(e) => onChange({ ...column, hide: !e.target.checked })}\n />\n }\n />\n <OptionsEditorControl\n label=\"Display\"\n control={\n <ButtonGroup aria-label=\"Display\" size=\"small\">\n <Button\n variant={!column.plugin ? 'contained' : 'outlined'}\n onClick={() => onChange({ ...column, plugin: undefined })}\n >\n Text\n </Button>\n <Button\n variant={column.plugin ? 'contained' : 'outlined'}\n onClick={() => onChange({ ...column, plugin: { kind: 'StatChart', spec: {} } })}\n >\n Embedded Panel\n </Button>\n </ButtonGroup>\n }\n />\n {column.plugin ? (\n <OptionsEditorControl\n label=\"Panel Type\"\n control={\n <PluginKindSelect\n pluginTypes={['Panel']}\n value={{ type: 'Panel', kind: column.plugin.kind }}\n onChange={(event) => onChange({ ...column, plugin: { kind: event.kind, spec: {} } })}\n />\n }\n />\n ) : (\n <FormatControls\n value={column.format ?? DEFAULT_FORMAT}\n onChange={(newFormat): void =>\n onChange({\n ...column,\n format: newFormat,\n })\n }\n />\n )}\n <OptionsEditorControl\n label=\"Alignment\"\n control={\n <AlignSelector\n size=\"small\"\n value={column.align ?? 'left'}\n onChange={(align) => onChange({ ...column, align: align })}\n />\n }\n />\n <OptionsEditorControl\n label=\"Custom width\"\n control={\n <Switch\n checked={column.width !== undefined && column.width !== 'auto'}\n onChange={(e) => onChange({ ...column, width: e.target.checked ? width : 'auto' })}\n />\n }\n />\n {column.width !== undefined && column.width !== 'auto' && (\n <OptionsEditorControl\n label=\"Width\"\n control={\n <TextField\n type=\"number\"\n value={width}\n slotProps={{ htmlInput: { min: 1 } }}\n onChange={(e) => {\n setWidth(+e.target.value);\n onChange({ ...column, width: +e.target.value });\n }}\n />\n }\n />\n )}\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Link\">\n <DataLinkEditor column={column} onChange={onChange} />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n <Stack sx={{ px: 8 }}>\n <OptionsEditorGroup title=\"Conditional Cell Format\">\n <ConditionalPanel\n cellSettings={column.cellSettings}\n onChange={(cellSettings) => onChange({ ...column, cellSettings })}\n />\n </OptionsEditorGroup>\n </Stack>\n </Stack>\n );\n}\n"],"names":["Button","ButtonGroup","Stack","Switch","TextField","useState","AlignSelector","FormatControls","OptionsEditorColumn","OptionsEditorControl","OptionsEditorGrid","OptionsEditorGroup","SortSelectorButtons","PluginKindSelect","ConditionalPanel","DataLinkEditor","DEFAULT_FORMAT","unit","shortValues","ColumnEditor","column","onChange","others","width","setWidth","undefined","title","label","control","value","name","e","target","required","header","headerDescription","cellDescription","checked","enableSorting","size","sort","sx","margin","hide","aria-label","variant","plugin","onClick","kind","spec","pluginTypes","type","event","format","newFormat","align","slotProps","htmlInput","min","px","cellSettings"],"mappings":";AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAcC,MAAM,EAAEC,SAAS,QAAQ,gBAAgB;AAC1F,SAAuBC,QAAQ,QAAQ,QAAQ;AAC/C,SACEC,aAAa,EACbC,cAAc,EACdC,mBAAmB,EACnBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,mBAAmB,QACd,yBAAyB;AAEhC,SAASC,gBAAgB,QAAQ,4BAA4B;AAG7D,SAASC,gBAAgB,QAAQ,sBAAsB;AACvD,SAASC,cAAc,QAAQ,yBAAyB;AAExD,MAAMC,iBAAgC;IACpCC,MAAM;IACNC,aAAa;AACf;AASA,OAAO,SAASC,aAAa,EAAEC,MAAM,EAAEC,QAAQ,EAAE,GAAGC,QAA2B;IAC7E,MAAM,CAACC,OAAOC,SAAS,GAAGnB,SACxBe,OAAOG,KAAK,KAAKE,aAAaL,OAAOG,KAAK,KAAK,SAAS,MAAMH,OAAOG,KAAK;IAG5E,qBACE,MAACrB;QAAO,GAAGoB,MAAM;;0BACf,MAACZ;;kCACC,KAACF;kCACC,cAAA,MAACG;4BAAmBe,OAAM;;8CACxB,KAACjB;oCACCkB,OAAM;oCACN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OAAM;oCACNC,uBACE,KAACtB;wCACCiC,MAAK;wCACLV,OAAOT,OAAOmC,KAAK,IAAI;wCACvBlC,UAAU,CAACkC,QAAUlC,SAAS;gDAAE,GAAGD,MAAM;gDAAEmC,OAAOA;4CAAM;;;8CAI9D,KAAC9C;oCACCkB,OAAM;oCACNC,uBACE,KAACzB;wCACCkC,SAASjB,OAAOG,KAAK,KAAKE,aAAaL,OAAOG,KAAK,KAAK;wCACxDF,UAAU,CAACU,IAAMV,SAAS;gDAAE,GAAGD,MAAM;gDAAEG,OAAOQ,EAAEC,MAAM,CAACK,OAAO,GAAGd,QAAQ;4CAAO;;;gCAIrFH,OAAOG,KAAK,KAAKE,aAAaL,OAAOG,KAAK,KAAK,wBAC9C,KAACd;oCACCkB,OAAM;oCACNC,uBACE,KAACxB;wCACC+C,MAAK;wCACLtB,OAAON;wCACPiC,WAAW;4CAAEC,WAAW;gDAAEC,KAAK;4CAAE;wCAAE;wCACnCrC,UAAU,CAACU;4CACTP,SAAS,CAACO,EAAEC,MAAM,CAACH,KAAK;4CACxBR,SAAS;gDAAE,GAAGD,MAAM;gDAAEG,OAAO,CAACQ,EAAEC,MAAM,CAACH,KAAK;4CAAC;wCAC/C;;;;;;kCAOZ,KAACrB;kCACC,cAAA,KAACG;4BAAmBe,OAAM;sCACxB,cAAA,KAACX;gCAAeK,QAAQA;gCAAQC,UAAUA;;;;;;0BAIhD,KAACnB;gBAAMuC,IAAI;oBAAEkB,IAAI;gBAAE;0BACjB,cAAA,KAAChD;oBAAmBe,OAAM;8BACxB,cAAA,KAACZ;wBACC8C,cAAcxC,OAAOwC,YAAY;wBACjCvC,UAAU,CAACuC,eAAiBvC,SAAS;gCAAE,GAAGD,MAAM;gCAAEwC;4BAAa;;;;;;AAM3E"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ColumnsEditor/ColumnEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Button, ButtonGroup, Stack, StackProps, Switch, TextField } from '@mui/material';\nimport { ReactElement, useState } from 'react';\nimport {\n AlignSelector,\n FormatControls,\n OptionsEditorColumn,\n OptionsEditorControl,\n OptionsEditorGrid,\n OptionsEditorGroup,\n SortSelectorButtons,\n} from '@perses-dev/components';\nimport { FormatOptions } from '@perses-dev/core';\nimport { PluginKindSelect } from '@perses-dev/plugin-system';\n\nimport { ColumnSettings } from '../../models';\nimport { ConditionalPanel } from '../ConditionalPanel';\nimport { DataLinkEditor } from './DataLinkEditorDialog';\n\nconst DEFAULT_FORMAT: FormatOptions = {\n unit: 'decimal',\n shortValues: true,\n};\n\ntype OmittedMuiProps = 'children' | 'value' | 'onChange';\n\nexport interface ColumnEditorProps extends Omit<StackProps, OmittedMuiProps> {\n column: ColumnSettings;\n onChange: (column: ColumnSettings) => void;\n}\n\nexport function ColumnEditor({ column, onChange, ...others }: ColumnEditorProps): ReactElement {\n const [width, setWidth] = useState<number>(\n column.width === undefined || column.width === 'auto' ? 100 : column.width\n );\n\n return (\n <Stack {...others}>\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Column\">\n <OptionsEditorControl\n label=\"Name*\"\n control={\n <TextField\n value={column.name}\n onChange={(e) => onChange({ ...column, name: e.target.value })}\n required\n />\n }\n />\n <OptionsEditorControl\n label=\"Header\"\n control={\n <TextField\n value={column.header ?? ''}\n onChange={(e) => onChange({ ...column, header: e.target.value ? e.target.value : undefined })}\n />\n }\n />\n <OptionsEditorControl\n label=\"Header Tooltip\"\n control={\n <TextField\n value={column.headerDescription ?? ''}\n onChange={(e) =>\n onChange({ ...column, headerDescription: e.target.value ? e.target.value : undefined })\n }\n />\n }\n />\n <OptionsEditorControl\n label=\"Cell Tooltip\"\n control={\n <TextField\n value={column.cellDescription ?? ''}\n onChange={(e) =>\n onChange({ ...column, cellDescription: e.target.value ? e.target.value : undefined })\n }\n />\n }\n />\n <OptionsEditorControl\n label=\"Enable sorting\"\n control={\n <Switch\n checked={column.enableSorting ?? false}\n onChange={(e) => onChange({ ...column, enableSorting: e.target.checked })}\n />\n }\n />\n {column.enableSorting && (\n <OptionsEditorControl\n label=\"Default Sort\"\n control={\n <SortSelectorButtons\n size=\"medium\"\n value={column.sort}\n sx={{\n margin: 0.5,\n }}\n onChange={(sort) => onChange({ ...column, sort: sort })}\n />\n }\n />\n )}\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Visual\">\n <OptionsEditorControl\n label=\"Show column\"\n control={\n <Switch\n checked={!(column.hide ?? false)}\n onChange={(e) => onChange({ ...column, hide: !e.target.checked })}\n />\n }\n />\n <OptionsEditorControl\n label=\"Display\"\n control={\n <ButtonGroup aria-label=\"Display\" size=\"small\">\n <Button\n variant={!column.plugin ? 'contained' : 'outlined'}\n onClick={() => onChange({ ...column, plugin: undefined })}\n >\n Text\n </Button>\n <Button\n variant={column.plugin ? 'contained' : 'outlined'}\n onClick={() => onChange({ ...column, plugin: { kind: 'StatChart', spec: {} } })}\n >\n Embedded Panel\n </Button>\n </ButtonGroup>\n }\n />\n {column.plugin ? (\n <OptionsEditorControl\n label=\"Panel Type\"\n control={\n <PluginKindSelect\n pluginTypes={['Panel']}\n value={{ type: 'Panel', kind: column.plugin.kind }}\n onChange={(event) => onChange({ ...column, plugin: { kind: event.kind, spec: {} } })}\n />\n }\n />\n ) : (\n <FormatControls\n value={column.format ?? DEFAULT_FORMAT}\n onChange={(newFormat): void =>\n onChange({\n ...column,\n format: newFormat,\n })\n }\n />\n )}\n <OptionsEditorControl\n label=\"Alignment\"\n control={\n <AlignSelector\n size=\"small\"\n value={column.align ?? 'left'}\n onChange={(align) => onChange({ ...column, align: align })}\n />\n }\n />\n <OptionsEditorControl\n label=\"Custom width\"\n control={\n <Switch\n checked={column.width !== undefined && column.width !== 'auto'}\n onChange={(e) => onChange({ ...column, width: e.target.checked ? width : 'auto' })}\n />\n }\n />\n {column.width !== undefined && column.width !== 'auto' && (\n <OptionsEditorControl\n label=\"Width\"\n control={\n <TextField\n type=\"number\"\n value={width}\n slotProps={{ htmlInput: { min: 1 } }}\n onChange={(e) => {\n setWidth(+e.target.value);\n onChange({ ...column, width: +e.target.value });\n }}\n />\n }\n />\n )}\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Link\">\n <DataLinkEditor column={column} onChange={onChange} />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n <Stack sx={{ px: 8 }}>\n <OptionsEditorGroup title=\"Conditional Cell Format\">\n <ConditionalPanel\n cellSettings={column.cellSettings}\n onChange={(cellSettings) => onChange({ ...column, cellSettings })}\n />\n </OptionsEditorGroup>\n </Stack>\n </Stack>\n );\n}\n"],"names":["Button","ButtonGroup","Stack","Switch","TextField","useState","AlignSelector","FormatControls","OptionsEditorColumn","OptionsEditorControl","OptionsEditorGrid","OptionsEditorGroup","SortSelectorButtons","PluginKindSelect","ConditionalPanel","DataLinkEditor","DEFAULT_FORMAT","unit","shortValues","ColumnEditor","column","onChange","others","width","setWidth","undefined","title","label","control","value","name","e","target","required","header","headerDescription","cellDescription","checked","enableSorting","size","sort","sx","margin","hide","aria-label","variant","plugin","onClick","kind","spec","pluginTypes","type","event","format","newFormat","align","slotProps","htmlInput","min","px","cellSettings"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAi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KAACxB;wCACC+C,MAAK;wCACLtB,OAAON;wCACPiC,WAAW;4CAAEC,WAAW;gDAAEC,KAAK;4CAAE;wCAAE;wCACnCrC,UAAU,CAACU;4CACTP,SAAS,CAACO,EAAEC,MAAM,CAACH,KAAK;4CACxBR,SAAS;gDAAE,GAAGD,MAAM;gDAAEG,OAAO,CAACQ,EAAEC,MAAM,CAACH,KAAK;4CAAC;wCAC/C;;;;;;kCAOZ,KAACrB;kCACC,cAAA,KAACG;4BAAmBe,OAAM;sCACxB,cAAA,KAACX;gCAAeK,QAAQA;gCAAQC,UAAUA;;;;;;0BAIhD,KAACnB;gBAAMuC,IAAI;oBAAEkB,IAAI;gBAAE;0BACjB,cAAA,KAAChD;oBAAmBe,OAAM;8BACxB,cAAA,KAACZ;wBACC8C,cAAcxC,OAAOwC,YAAY;wBACjCvC,UAAU,CAACuC,eAAiBvC,SAAS;gCAAE,GAAGD,MAAM;gCAAEwC;4BAAa;;;;;;AAM3E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
5
5
|
// You may obtain a copy of the License at
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ColumnsEditor/ColumnEditorContainer.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ColumnsEditor/ColumnEditorContainer.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Divider, IconButton, Stack, Tooltip, Typography } from '@mui/material';\nimport ChevronRight from 'mdi-material-ui/ChevronRight';\nimport ChevronDown from 'mdi-material-ui/ChevronDown';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport EyeIcon from 'mdi-material-ui/EyeOutline';\nimport EyeOffIcon from 'mdi-material-ui/EyeOffOutline';\nimport { DragAndDropElement, DragButton } from '@perses-dev/components';\nimport { ReactElement } from 'react';\nimport { ColumnEditor, ColumnEditorProps } from './ColumnEditor';\n\nexport interface ColumnEditorContainerProps extends ColumnEditorProps {\n isCollapsed: boolean;\n onCollapse: (collapsed: boolean) => void;\n onDelete: () => void;\n onMoveUp: () => void;\n onMoveDown: () => void;\n}\n\nexport function ColumnEditorContainer({\n column,\n isCollapsed,\n onChange,\n onCollapse,\n onDelete,\n onMoveUp,\n onMoveDown,\n}: ColumnEditorContainerProps): ReactElement {\n function handleHideColumn(): void {\n onChange({ ...column, hide: !column.hide });\n }\n\n return (\n <DragAndDropElement data={column as unknown as Record<string, unknown>}>\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n borderBottom={1}\n borderColor={(theme) => theme.palette.divider}\n justifyContent=\"space-between\"\n gap={4}\n >\n <Stack direction=\"row\" gap={1}>\n <IconButton\n data-testid={`column-toggle#${column.name}`}\n size=\"small\"\n onClick={() => onCollapse(!isCollapsed)}\n >\n {isCollapsed ? <ChevronRight /> : <ChevronDown />}\n </IconButton>\n <Typography variant=\"overline\" component=\"h4\" sx={{ textTransform: 'none' }}>\n COLUMN:{' '}\n {column.header ? (\n <span>\n <strong>{column.header}</strong> ({column.name})\n </span>\n ) : (\n <strong>{column.name}</strong>\n )}\n </Typography>\n </Stack>\n\n <Stack direction=\"row\" gap={1}>\n {isCollapsed && (\n <>\n <Tooltip title={column.hide ? 'Show column' : 'Hide column'} placement=\"top\">\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={handleHideColumn} key=\"hide-column\">\n {column.hide ? <EyeOffIcon /> : <EyeIcon />}\n </IconButton>\n </Tooltip>\n <Divider flexItem orientation=\"vertical\" variant=\"middle\" />\n </>\n )}\n <Tooltip title=\"Remove column settings\" placement=\"top\">\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={onDelete} key=\"delete-column-button\">\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n <Tooltip title=\"Reorder column settings\" placement=\"top\">\n <DragButton\n onMoveUp={onMoveUp}\n onMoveDown={onMoveDown}\n menuSx={{\n '.MuiPaper-root': { backgroundColor: (theme) => theme.palette.background.lighter },\n }}\n key=\"reorder-column-button\"\n />\n </Tooltip>\n </Stack>\n </Stack>\n\n {/* When a <Grid> is inside a <Stack> with gap, the negative margin of the grid is not applied. Therefore, let's wrap it in a div. */}\n {!isCollapsed && (\n <div>\n <ColumnEditor column={column} onChange={onChange} />\n </div>\n )}\n </DragAndDropElement>\n );\n}\n"],"names":["Divider","IconButton","Stack","Tooltip","Typography","ChevronRight","ChevronDown","DeleteIcon","EyeIcon","EyeOffIcon","DragAndDropElement","DragButton","ColumnEditor","ColumnEditorContainer","column","isCollapsed","onChange","onCollapse","onDelete","onMoveUp","onMoveDown","handleHideColumn","hide","data","direction","alignItems","borderBottom","borderColor","theme","palette","divider","justifyContent","gap","data-testid","name","size","onClick","variant","component","sx","textTransform","header","span","strong","title","placement","marginLeft","flexItem","orientation","menuSx","backgroundColor","background","lighter","div"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,QAAQ,gBAAgB;AAChF,OAAOC,kBAAkB,+BAA+B;AAC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4CAAQI,IAAI;gDAAEO,YAAY;4CAAO;4CAAGV,SAASf;sDAC3DP,OAAOQ,IAAI,iBAAG,KAACb,gCAAgB,KAACD;2CADiD;;kDAItF,KAACR;wCAAQ+C,QAAQ;wCAACC,aAAY;wCAAWX,SAAQ;;;;0CAGrD,KAAClC;gCAAQyC,OAAM;gCAAyBC,WAAU;0CAChD,cAAA,KAAC5C;oCAAWkC,MAAK;oCAAQI,IAAI;wCAAEO,YAAY;oCAAO;oCAAGV,SAASlB;8CAC5D,cAAA,KAACX;mCADyE;;0CAI9E,KAACJ;gCAAQyC,OAAM;gCAA0BC,WAAU;0CACjD,cAAA,KAAClC;oCACCQ,UAAUA;oCACVC,YAAYA;oCACZ6B,QAAQ;wCACN,kBAAkB;4CAAEC,iBAAiB,CAACtB,QAAUA,MAAMC,OAAO,CAACsB,UAAU,CAACC,OAAO;wCAAC;oCACnF;mCACI;;;;;;YAOX,CAACrC,6BACA,KAACsC;0BACC,cAAA,KAACzC;oBAAaE,QAAQA;oBAAQE,UAAUA;;;;;AAKlD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
5
5
|
// You may obtain a copy of the License at
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/ColumnsEditor/ColumnsEditor.tsx"],"sourcesContent":["// Copyright
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/ColumnsEditor/ColumnsEditor.tsx"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Button, Stack } from '@mui/material';\nimport { ReactElement, useState } from 'react';\nimport AddIcon from 'mdi-material-ui/Plus';\nimport { handleMoveDown, handleMoveUp, useDragAndDropMonitor } from '@perses-dev/components';\nimport { ColumnSettings } from '../../models';\nimport { ColumnEditorContainer } from './ColumnEditorContainer';\n\nexport interface ColumnsEditorProps {\n columnSettings: ColumnSettings[];\n onChange: (columnOptions: ColumnSettings[]) => void;\n}\n\nexport function ColumnsEditor({ columnSettings, onChange }: ColumnsEditorProps): ReactElement {\n const [columnsCollapsed, setColumnsCollapsed] = useState(columnSettings.map(() => true));\n\n function handleColumnChange(index: number, column: ColumnSettings): void {\n const updatedColumns = [...columnSettings];\n updatedColumns[index] = column;\n onChange(updatedColumns);\n }\n\n function handleColumnAdd(): void {\n const columnName: string = `column_${Object.keys(columnSettings).length}`;\n const updatedColumns = [...columnSettings];\n updatedColumns.push({ name: columnName });\n onChange(updatedColumns);\n setColumnsCollapsed((prev) => {\n prev.push(false);\n return [...prev];\n });\n }\n\n function handleColumnDelete(index: number): void {\n const updatedColumns = [...columnSettings];\n updatedColumns.splice(index, 1);\n onChange(updatedColumns);\n setColumnsCollapsed((prev) => {\n prev.splice(index, 1);\n return [...prev];\n });\n }\n\n function handleColumnCollapseExpand(index: number, collapsed: boolean): void {\n setColumnsCollapsed((prev) => {\n prev[index] = collapsed;\n return [...prev];\n });\n }\n\n useDragAndDropMonitor({\n elements: columnSettings as unknown as Array<Record<string, unknown>>,\n accessKey: 'name',\n onChange: onChange as unknown as (elements: Array<Record<string, unknown>>) => void,\n });\n\n return (\n <Stack spacing={1}>\n {columnSettings.map((column, i) => (\n <ColumnEditorContainer\n key={i}\n column={column}\n isCollapsed={columnsCollapsed[i] ?? true}\n onChange={(updatedColumn: ColumnSettings) => handleColumnChange(i, updatedColumn)}\n onDelete={() => handleColumnDelete(i)}\n onCollapse={(collapsed) => handleColumnCollapseExpand(i, collapsed)}\n onMoveUp={() => onChange(handleMoveUp(column, columnSettings))}\n onMoveDown={() => onChange(handleMoveDown(column, columnSettings))}\n />\n ))}\n\n <Button variant=\"contained\" startIcon={<AddIcon />} sx={{ marginTop: 1 }} onClick={handleColumnAdd}>\n Add Column Settings\n </Button>\n </Stack>\n );\n}\n"],"names":["Button","Stack","useState","AddIcon","handleMoveDown","handleMoveUp","useDragAndDropMonitor","ColumnEditorContainer","ColumnsEditor","columnSettings","onChange","columnsCollapsed","setColumnsCollapsed","map","handleColumnChange","index","column","updatedColumns","handleColumnAdd","columnName","Object","keys","length","push","name","prev","handleColumnDelete","splice","handleColumnCollapseExpand","collapsed","elements","accessKey","spacing","i","isCollapsed","updatedColumn","onDelete","onCollapse","onMoveUp","onMoveDown","variant","startIcon","sx","marginTop","onClick"],"mappings":";AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAC9C,SAAuBC,QAAQ,QAAQ,QAAQ;AAC/C,OAAOC,aAAa,uBAAuB;AAC3C,SAASC,cAAc,EAAEC,YAAY,EAAEC,qBAAqB,QAAQ,yBAAyB;AAE7F,SAASC,qBAAqB,QAAQ,0BAA0B;AAOhE,OAAO,SAASC,cAAc,EAAEC,cAAc,EAAEC,QAAQ,EAAsB;IAC5E,MAAM,CAACC,kBAAkBC,oBAAoB,GAAGV,SAASO,eAAeI,GAAG,CAAC,IAAM;IAElF,SAASC,mBAAmBC,KAAa,EAAEC,MAAsB;QAC/D,MAAMC,iBAAiB;eAAIR;SAAe;QAC1CQ,cAAc,CAACF,MAAM,GAAGC;QACxBN,SAASO;IACX;IAEA,SAASC;QACP,MA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"react/jsx-runtime";
|
|
2
|
-
// Copyright
|
|
2
|
+
// Copyright The Perses Authors
|
|
3
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
4
|
// you may not use this file except in compliance with the License.
|
|
5
5
|
// You may obtain a copy of the License at
|