@perses-dev/table-plugin 0.8.1 → 0.10.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/css/async/2341.d3010b86.css +1 -0
- package/__mf/css/async/5263.d3010b86.css +1 -0
- package/__mf/css/async/6759.d3010b86.css +1 -0
- package/__mf/js/{Table.1ddb6c06.js → Table.02a0172e.js} +4 -4
- package/__mf/js/async/2178.23b43aaf.js +1 -0
- package/__mf/js/async/2472.d6b3b5c6.js +22 -0
- package/__mf/js/async/2849.0d68beb5.js +2 -0
- package/__mf/js/async/{4075.e2a2c230.js → 4075.98f26cf8.js} +1 -1
- package/__mf/js/async/{4238.ea9515aa.js → 4238.8989501f.js} +1 -1
- package/__mf/js/async/6377.1f2ba730.js +38 -0
- package/__mf/js/async/9830.a2983642.js +7 -0
- package/__mf/js/async/__federation_expose_Table.0dbf0d6d.js +1 -0
- package/__mf/js/{main.688de0b9.js → main.f7b12b00.js} +4 -4
- package/lib/Table.d.ts +2 -2
- package/lib/Table.d.ts.map +1 -1
- package/lib/Table.js +2 -6
- package/lib/Table.js.map +1 -1
- package/lib/cjs/Table.js +9 -13
- package/lib/cjs/components/CellsEditor/CellsEditor.js +30 -0
- package/lib/cjs/{CellsEditor → components/CellsEditor}/index.js +0 -1
- package/lib/cjs/components/ColumnsEditor/ColumnEditor.js +241 -0
- package/lib/cjs/{CellsEditor/CellEditor.js → components/ConditionalPanel.js} +167 -197
- package/lib/cjs/components/TablePanel.js +576 -0
- package/lib/cjs/{TableSettingsEditor.js → components/TableSettingsEditor.js} +32 -4
- package/lib/cjs/components/index.js +37 -0
- package/lib/cjs/index.js +2 -9
- package/lib/cjs/models/index.js +31 -0
- package/lib/cjs/{table-model.js → models/model.js} +1 -12
- package/lib/cjs/models/table-model.js +252 -0
- package/lib/{CellsEditor → components/CellsEditor}/CellsEditor.d.ts +1 -1
- package/lib/components/CellsEditor/CellsEditor.d.ts.map +1 -0
- package/lib/components/CellsEditor/CellsEditor.js +22 -0
- package/lib/components/CellsEditor/CellsEditor.js.map +1 -0
- package/lib/components/CellsEditor/index.d.ts +2 -0
- package/lib/components/CellsEditor/index.d.ts.map +1 -0
- package/lib/{CellsEditor → components/CellsEditor}/index.js +0 -1
- package/lib/components/CellsEditor/index.js.map +1 -0
- package/lib/{ColumnsEditor → components/ColumnsEditor}/ColumnEditor.d.ts +1 -1
- package/lib/components/ColumnsEditor/ColumnEditor.d.ts.map +1 -0
- package/lib/components/ColumnsEditor/ColumnEditor.js +233 -0
- package/lib/components/ColumnsEditor/ColumnEditor.js.map +1 -0
- package/lib/components/ColumnsEditor/ColumnEditorContainer.d.ts.map +1 -0
- package/lib/components/ColumnsEditor/ColumnEditorContainer.js.map +1 -0
- package/lib/{ColumnsEditor → components/ColumnsEditor}/ColumnsEditor.d.ts +1 -1
- package/lib/components/ColumnsEditor/ColumnsEditor.d.ts.map +1 -0
- package/lib/components/ColumnsEditor/ColumnsEditor.js.map +1 -0
- package/lib/components/ColumnsEditor/index.d.ts.map +1 -0
- package/lib/components/ColumnsEditor/index.js.map +1 -0
- package/lib/components/ConditionalPanel.d.ts +15 -0
- package/lib/components/ConditionalPanel.d.ts.map +1 -0
- package/lib/{CellsEditor/CellEditor.js → components/ConditionalPanel.js} +159 -197
- package/lib/components/ConditionalPanel.js.map +1 -0
- package/lib/components/EmbeddedPanel.d.ts.map +1 -0
- package/lib/components/EmbeddedPanel.js.map +1 -0
- package/lib/{TableCellsEditor.d.ts → components/TableCellsEditor.d.ts} +1 -1
- package/lib/components/TableCellsEditor.d.ts.map +1 -0
- package/lib/components/TableCellsEditor.js.map +1 -0
- package/lib/{TableColumnsEditor.d.ts → components/TableColumnsEditor.d.ts} +1 -1
- package/lib/components/TableColumnsEditor.d.ts.map +1 -0
- package/lib/components/TableColumnsEditor.js.map +1 -0
- package/lib/{TablePanel.d.ts → components/TablePanel.d.ts} +1 -1
- package/lib/components/TablePanel.d.ts.map +1 -0
- package/lib/components/TablePanel.js +560 -0
- package/lib/components/TablePanel.js.map +1 -0
- package/lib/{TableSettingsEditor.d.ts → components/TableSettingsEditor.d.ts} +1 -1
- package/lib/components/TableSettingsEditor.d.ts.map +1 -0
- package/lib/{TableSettingsEditor.js → components/TableSettingsEditor.js} +32 -4
- package/lib/components/TableSettingsEditor.js.map +1 -0
- package/lib/{TableTransformsEditor.d.ts → components/TableTransformsEditor.d.ts} +1 -1
- package/lib/components/TableTransformsEditor.d.ts.map +1 -0
- package/lib/components/TableTransformsEditor.js.map +1 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.d.ts.map +1 -0
- package/lib/components/index.js +22 -0
- package/lib/components/index.js.map +1 -0
- package/lib/index.d.ts +2 -9
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -9
- package/lib/index.js.map +1 -1
- package/lib/models/index.d.ts +3 -0
- package/lib/models/index.d.ts.map +1 -0
- package/lib/{table-model.js → models/index.js} +4 -9
- package/lib/models/index.js.map +1 -0
- package/lib/models/model.d.ts.map +1 -0
- package/lib/models/model.js +15 -0
- package/lib/models/model.js.map +1 -0
- package/lib/{table-model.d.ts → models/table-model.d.ts} +24 -1
- package/lib/models/table-model.d.ts.map +1 -0
- package/lib/models/table-model.js +233 -0
- package/lib/models/table-model.js.map +1 -0
- package/mf-manifest.json +21 -22
- package/mf-stats.json +22 -23
- package/package.json +6 -6
- package/__mf/css/async/2341.cbbd94a8.css +0 -1
- package/__mf/css/async/5263.cbbd94a8.css +0 -1
- package/__mf/css/async/6759.cbbd94a8.css +0 -1
- package/__mf/js/async/3391.62c7afd4.js +0 -73
- package/__mf/js/async/4300.fc319dfb.js +0 -38
- package/__mf/js/async/4368.3e460b07.js +0 -1
- package/__mf/js/async/5061.85655462.js +0 -2
- package/__mf/js/async/5377.6522c49a.js +0 -1
- package/__mf/js/async/8313.b86a056a.js +0 -7
- package/__mf/js/async/__federation_expose_Table.3668e352.js +0 -1
- package/lib/CellsEditor/CellEditor.d.ts +0 -10
- package/lib/CellsEditor/CellEditor.d.ts.map +0 -1
- package/lib/CellsEditor/CellEditor.js.map +0 -1
- package/lib/CellsEditor/CellsEditor.d.ts.map +0 -1
- package/lib/CellsEditor/CellsEditor.js +0 -123
- package/lib/CellsEditor/CellsEditor.js.map +0 -1
- package/lib/CellsEditor/index.d.ts +0 -3
- package/lib/CellsEditor/index.d.ts.map +0 -1
- package/lib/CellsEditor/index.js.map +0 -1
- package/lib/ColumnsEditor/ColumnEditor.d.ts.map +0 -1
- package/lib/ColumnsEditor/ColumnEditor.js +0 -213
- package/lib/ColumnsEditor/ColumnEditor.js.map +0 -1
- package/lib/ColumnsEditor/ColumnEditorContainer.d.ts.map +0 -1
- package/lib/ColumnsEditor/ColumnEditorContainer.js.map +0 -1
- package/lib/ColumnsEditor/ColumnsEditor.d.ts.map +0 -1
- package/lib/ColumnsEditor/ColumnsEditor.js.map +0 -1
- package/lib/ColumnsEditor/index.d.ts.map +0 -1
- package/lib/ColumnsEditor/index.js.map +0 -1
- package/lib/EmbeddedPanel.d.ts.map +0 -1
- package/lib/EmbeddedPanel.js.map +0 -1
- package/lib/TableCellsEditor.d.ts.map +0 -1
- package/lib/TableCellsEditor.js.map +0 -1
- package/lib/TableColumnsEditor.d.ts.map +0 -1
- package/lib/TableColumnsEditor.js.map +0 -1
- package/lib/TablePanel.d.ts.map +0 -1
- package/lib/TablePanel.js +0 -325
- package/lib/TablePanel.js.map +0 -1
- package/lib/TableSettingsEditor.d.ts.map +0 -1
- package/lib/TableSettingsEditor.js.map +0 -1
- package/lib/TableTransformsEditor.d.ts.map +0 -1
- package/lib/TableTransformsEditor.js.map +0 -1
- package/lib/cjs/CellsEditor/CellsEditor.js +0 -136
- package/lib/cjs/ColumnsEditor/ColumnEditor.js +0 -221
- package/lib/cjs/TablePanel.js +0 -341
- package/lib/cjs/model.js +0 -4
- package/lib/model.d.ts.map +0 -1
- package/lib/model.js +0 -3
- package/lib/model.js.map +0 -1
- package/lib/table-model.d.ts.map +0 -1
- package/lib/table-model.js.map +0 -1
- /package/__mf/js/async/{3391.62c7afd4.js.LICENSE.txt → 2472.d6b3b5c6.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{5061.85655462.js.LICENSE.txt → 2849.0d68beb5.js.LICENSE.txt} +0 -0
- /package/__mf/js/async/{8313.b86a056a.js.LICENSE.txt → 9830.a2983642.js.LICENSE.txt} +0 -0
- /package/lib/cjs/{ColumnsEditor → components/ColumnsEditor}/ColumnEditorContainer.js +0 -0
- /package/lib/cjs/{ColumnsEditor → components/ColumnsEditor}/ColumnsEditor.js +0 -0
- /package/lib/cjs/{ColumnsEditor → components/ColumnsEditor}/index.js +0 -0
- /package/lib/cjs/{EmbeddedPanel.js → components/EmbeddedPanel.js} +0 -0
- /package/lib/cjs/{TableCellsEditor.js → components/TableCellsEditor.js} +0 -0
- /package/lib/cjs/{TableColumnsEditor.js → components/TableColumnsEditor.js} +0 -0
- /package/lib/cjs/{TableTransformsEditor.js → components/TableTransformsEditor.js} +0 -0
- /package/lib/{ColumnsEditor → components/ColumnsEditor}/ColumnEditorContainer.d.ts +0 -0
- /package/lib/{ColumnsEditor → components/ColumnsEditor}/ColumnEditorContainer.js +0 -0
- /package/lib/{ColumnsEditor → components/ColumnsEditor}/ColumnsEditor.js +0 -0
- /package/lib/{ColumnsEditor → components/ColumnsEditor}/index.d.ts +0 -0
- /package/lib/{ColumnsEditor → components/ColumnsEditor}/index.js +0 -0
- /package/lib/{EmbeddedPanel.d.ts → components/EmbeddedPanel.d.ts} +0 -0
- /package/lib/{EmbeddedPanel.js → components/EmbeddedPanel.js} +0 -0
- /package/lib/{TableCellsEditor.js → components/TableCellsEditor.js} +0 -0
- /package/lib/{TableColumnsEditor.js → components/TableColumnsEditor.js} +0 -0
- /package/lib/{TableTransformsEditor.js → components/TableTransformsEditor.js} +0 -0
- /package/lib/{model.d.ts → models/model.d.ts} +0 -0
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"use strict";
|
|
14
|
-
Object.defineProperty(exports, "__esModule", {
|
|
15
|
-
value: true
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "ColumnEditor", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function() {
|
|
20
|
-
return ColumnEditor;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
24
|
-
const _material = require("@mui/material");
|
|
25
|
-
const _react = require("react");
|
|
26
|
-
const _components = require("@perses-dev/components");
|
|
27
|
-
const _pluginsystem = require("@perses-dev/plugin-system");
|
|
28
|
-
const DEFAULT_FORMAT = {
|
|
29
|
-
unit: 'decimal',
|
|
30
|
-
shortValues: true
|
|
31
|
-
};
|
|
32
|
-
function ColumnEditor({ column, onChange, ...others }) {
|
|
33
|
-
const [width, setWidth] = (0, _react.useState)(column.width === undefined || column.width === 'auto' ? 100 : column.width);
|
|
34
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
|
|
35
|
-
...others,
|
|
36
|
-
children: [
|
|
37
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
|
|
38
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
39
|
-
title: "Column",
|
|
40
|
-
children: [
|
|
41
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
42
|
-
label: "Name*",
|
|
43
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
44
|
-
value: column.name,
|
|
45
|
-
onChange: (e)=>onChange({
|
|
46
|
-
...column,
|
|
47
|
-
name: e.target.value
|
|
48
|
-
}),
|
|
49
|
-
required: true
|
|
50
|
-
})
|
|
51
|
-
}),
|
|
52
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
53
|
-
label: "Header",
|
|
54
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
55
|
-
value: column.header ?? '',
|
|
56
|
-
onChange: (e)=>onChange({
|
|
57
|
-
...column,
|
|
58
|
-
header: e.target.value ? e.target.value : undefined
|
|
59
|
-
})
|
|
60
|
-
})
|
|
61
|
-
}),
|
|
62
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
63
|
-
label: "Header Tooltip",
|
|
64
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
65
|
-
value: column.headerDescription ?? '',
|
|
66
|
-
onChange: (e)=>onChange({
|
|
67
|
-
...column,
|
|
68
|
-
headerDescription: e.target.value ? e.target.value : undefined
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
}),
|
|
72
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
73
|
-
label: "Cell Tooltip",
|
|
74
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
75
|
-
value: column.cellDescription ?? '',
|
|
76
|
-
onChange: (e)=>onChange({
|
|
77
|
-
...column,
|
|
78
|
-
cellDescription: e.target.value ? e.target.value : undefined
|
|
79
|
-
})
|
|
80
|
-
})
|
|
81
|
-
}),
|
|
82
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
83
|
-
label: "Enable sorting",
|
|
84
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
85
|
-
checked: column.enableSorting ?? false,
|
|
86
|
-
onChange: (e)=>onChange({
|
|
87
|
-
...column,
|
|
88
|
-
enableSorting: e.target.checked
|
|
89
|
-
})
|
|
90
|
-
})
|
|
91
|
-
}),
|
|
92
|
-
column.enableSorting && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
93
|
-
label: "Default Sort",
|
|
94
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.SortSelectorButtons, {
|
|
95
|
-
size: "medium",
|
|
96
|
-
value: column.sort,
|
|
97
|
-
sx: {
|
|
98
|
-
margin: 0.5
|
|
99
|
-
},
|
|
100
|
-
onChange: (sort)=>onChange({
|
|
101
|
-
...column,
|
|
102
|
-
sort: sort
|
|
103
|
-
})
|
|
104
|
-
})
|
|
105
|
-
})
|
|
106
|
-
]
|
|
107
|
-
})
|
|
108
|
-
}),
|
|
109
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
|
|
110
|
-
children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGroup, {
|
|
111
|
-
title: "Visual",
|
|
112
|
-
children: [
|
|
113
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
114
|
-
label: "Show column",
|
|
115
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
116
|
-
checked: !(column.hide ?? false),
|
|
117
|
-
onChange: (e)=>onChange({
|
|
118
|
-
...column,
|
|
119
|
-
hide: !e.target.checked
|
|
120
|
-
})
|
|
121
|
-
})
|
|
122
|
-
}),
|
|
123
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
124
|
-
label: "Display",
|
|
125
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.ButtonGroup, {
|
|
126
|
-
"aria-label": "Display",
|
|
127
|
-
size: "small",
|
|
128
|
-
children: [
|
|
129
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
130
|
-
variant: !column.plugin ? 'contained' : 'outlined',
|
|
131
|
-
onClick: ()=>onChange({
|
|
132
|
-
...column,
|
|
133
|
-
plugin: undefined
|
|
134
|
-
}),
|
|
135
|
-
children: "Text"
|
|
136
|
-
}),
|
|
137
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
|
|
138
|
-
variant: column.plugin ? 'contained' : 'outlined',
|
|
139
|
-
onClick: ()=>onChange({
|
|
140
|
-
...column,
|
|
141
|
-
plugin: {
|
|
142
|
-
kind: 'StatChart',
|
|
143
|
-
spec: {}
|
|
144
|
-
}
|
|
145
|
-
}),
|
|
146
|
-
children: "Embedded Panel"
|
|
147
|
-
})
|
|
148
|
-
]
|
|
149
|
-
})
|
|
150
|
-
}),
|
|
151
|
-
column.plugin ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
152
|
-
label: "Panel Type",
|
|
153
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.PluginKindSelect, {
|
|
154
|
-
pluginTypes: [
|
|
155
|
-
'Panel'
|
|
156
|
-
],
|
|
157
|
-
value: {
|
|
158
|
-
type: 'Panel',
|
|
159
|
-
kind: column.plugin.kind
|
|
160
|
-
},
|
|
161
|
-
onChange: (event)=>onChange({
|
|
162
|
-
...column,
|
|
163
|
-
plugin: {
|
|
164
|
-
kind: event.kind,
|
|
165
|
-
spec: {}
|
|
166
|
-
}
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.FormatControls, {
|
|
170
|
-
value: column.format ?? DEFAULT_FORMAT,
|
|
171
|
-
onChange: (newFormat)=>onChange({
|
|
172
|
-
...column,
|
|
173
|
-
format: newFormat
|
|
174
|
-
})
|
|
175
|
-
}),
|
|
176
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
177
|
-
label: "Alignment",
|
|
178
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.AlignSelector, {
|
|
179
|
-
size: "small",
|
|
180
|
-
value: column.align ?? 'left',
|
|
181
|
-
onChange: (align)=>onChange({
|
|
182
|
-
...column,
|
|
183
|
-
align: align
|
|
184
|
-
})
|
|
185
|
-
})
|
|
186
|
-
}),
|
|
187
|
-
/*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
188
|
-
label: "Custom width",
|
|
189
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Switch, {
|
|
190
|
-
checked: column.width !== undefined && column.width !== 'auto',
|
|
191
|
-
onChange: (e)=>onChange({
|
|
192
|
-
...column,
|
|
193
|
-
width: e.target.checked ? width : 'auto'
|
|
194
|
-
})
|
|
195
|
-
})
|
|
196
|
-
}),
|
|
197
|
-
column.width !== undefined && column.width !== 'auto' && /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorControl, {
|
|
198
|
-
label: "Width",
|
|
199
|
-
control: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TextField, {
|
|
200
|
-
type: "number",
|
|
201
|
-
value: width,
|
|
202
|
-
slotProps: {
|
|
203
|
-
htmlInput: {
|
|
204
|
-
min: 1
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
onChange: (e)=>{
|
|
208
|
-
setWidth(+e.target.value);
|
|
209
|
-
onChange({
|
|
210
|
-
...column,
|
|
211
|
-
width: +e.target.value
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
})
|
|
215
|
-
})
|
|
216
|
-
]
|
|
217
|
-
})
|
|
218
|
-
})
|
|
219
|
-
]
|
|
220
|
-
});
|
|
221
|
-
}
|
package/lib/cjs/TablePanel.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Perses Authors
|
|
2
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
-
// you may not use this file except in compliance with the License.
|
|
4
|
-
// You may obtain a copy of the License at
|
|
5
|
-
//
|
|
6
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
-
//
|
|
8
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
-
// See the License for the specific language governing permissions and
|
|
12
|
-
// limitations under the License.
|
|
13
|
-
"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: all[name]
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
_export(exports, {
|
|
24
|
-
TablePanel: function() {
|
|
25
|
-
return TablePanel;
|
|
26
|
-
},
|
|
27
|
-
getTablePanelQueryOptions: function() {
|
|
28
|
-
return getTablePanelQueryOptions;
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
const _jsxruntime = require("react/jsx-runtime");
|
|
32
|
-
const _components = require("@perses-dev/components");
|
|
33
|
-
const _react = require("react");
|
|
34
|
-
const _core = require("@perses-dev/core");
|
|
35
|
-
const _EmbeddedPanel = require("./EmbeddedPanel");
|
|
36
|
-
function generateCellContentConfig(column) {
|
|
37
|
-
const plugin = column.plugin;
|
|
38
|
-
if (plugin !== undefined) {
|
|
39
|
-
return {
|
|
40
|
-
cell: (ctx)=>{
|
|
41
|
-
const panelData = ctx.getValue();
|
|
42
|
-
if (!panelData) return /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {});
|
|
43
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_EmbeddedPanel.EmbeddedPanel, {
|
|
44
|
-
kind: plugin.kind,
|
|
45
|
-
spec: plugin.spec,
|
|
46
|
-
queryResults: [
|
|
47
|
-
panelData
|
|
48
|
-
]
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
cellDescription: column.cellDescription ? ()=>`${column.cellDescription}` : ()=>''
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
cell: (ctx)=>{
|
|
56
|
-
const cellValue = ctx.getValue();
|
|
57
|
-
return typeof cellValue === 'number' && column.format ? (0, _core.formatValue)(cellValue, column.format) : cellValue;
|
|
58
|
-
},
|
|
59
|
-
cellDescription: column.cellDescription ? ()=>`${column.cellDescription}` : undefined
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/*
|
|
63
|
-
* Generate column config from column definitions, if a column has multiple definitions, the first one will be used.
|
|
64
|
-
* If column is hidden, return undefined.
|
|
65
|
-
* If column do not have a definition, return a default column config.
|
|
66
|
-
*/ function generateColumnConfig(name, columnSettings) {
|
|
67
|
-
for (const column of columnSettings){
|
|
68
|
-
if (column.name === name) {
|
|
69
|
-
if (column.hide) {
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
accessorKey: name,
|
|
74
|
-
header: column.header ?? name,
|
|
75
|
-
headerDescription: column.headerDescription,
|
|
76
|
-
enableSorting: column.enableSorting,
|
|
77
|
-
width: column.width,
|
|
78
|
-
align: column.align,
|
|
79
|
-
...generateCellContentConfig(column)
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
accessorKey: name,
|
|
85
|
-
header: name
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
function generateCellConfig(value, settings) {
|
|
89
|
-
for (const setting of settings){
|
|
90
|
-
if (setting.condition.kind === 'Value' && setting.condition.spec?.value === String(value)) {
|
|
91
|
-
return {
|
|
92
|
-
text: setting.text,
|
|
93
|
-
textColor: setting.textColor,
|
|
94
|
-
backgroundColor: setting.backgroundColor
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
if (setting.condition.kind === 'Range' && !Number.isNaN(Number(value))) {
|
|
98
|
-
const numericValue = Number(value);
|
|
99
|
-
if (setting.condition.spec?.min !== undefined && setting.condition.spec?.max !== undefined && numericValue >= +setting.condition.spec?.min && numericValue <= +setting.condition.spec?.max) {
|
|
100
|
-
return {
|
|
101
|
-
text: setting.text,
|
|
102
|
-
textColor: setting.textColor,
|
|
103
|
-
backgroundColor: setting.backgroundColor
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
if (setting.condition.spec?.min !== undefined && numericValue >= +setting.condition.spec?.min) {
|
|
107
|
-
return {
|
|
108
|
-
text: setting.text,
|
|
109
|
-
textColor: setting.textColor,
|
|
110
|
-
backgroundColor: setting.backgroundColor
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
if (setting.condition.spec?.max !== undefined && numericValue <= +setting.condition.spec?.max) {
|
|
114
|
-
return {
|
|
115
|
-
text: setting.text,
|
|
116
|
-
textColor: setting.textColor,
|
|
117
|
-
backgroundColor: setting.backgroundColor
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (setting.condition.kind === 'Regex' && setting.condition.spec?.expr) {
|
|
122
|
-
const regex = new RegExp(setting.condition.spec?.expr);
|
|
123
|
-
if (regex.test(String(value))) {
|
|
124
|
-
return {
|
|
125
|
-
text: setting.text,
|
|
126
|
-
textColor: setting.textColor,
|
|
127
|
-
backgroundColor: setting.backgroundColor
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (setting.condition.kind === 'Misc' && setting.condition.spec?.value) {
|
|
132
|
-
if (setting.condition.spec?.value === 'empty' && value === '') {
|
|
133
|
-
return {
|
|
134
|
-
text: setting.text,
|
|
135
|
-
textColor: setting.textColor,
|
|
136
|
-
backgroundColor: setting.backgroundColor
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
if (setting.condition.spec?.value === 'null' && (value === null || value === undefined)) {
|
|
140
|
-
return {
|
|
141
|
-
text: setting.text,
|
|
142
|
-
textColor: setting.textColor,
|
|
143
|
-
backgroundColor: setting.backgroundColor
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
if (setting.condition.spec?.value === 'NaN' && Number.isNaN(value)) {
|
|
147
|
-
return {
|
|
148
|
-
text: setting.text,
|
|
149
|
-
textColor: setting.textColor,
|
|
150
|
-
backgroundColor: setting.backgroundColor
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
if (setting.condition.spec?.value === 'true' && value === true) {
|
|
154
|
-
return {
|
|
155
|
-
text: setting.text,
|
|
156
|
-
textColor: setting.textColor,
|
|
157
|
-
backgroundColor: setting.backgroundColor
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
if (setting.condition.spec?.value === 'false' && value === false) {
|
|
161
|
-
return {
|
|
162
|
-
text: setting.text,
|
|
163
|
-
textColor: setting.textColor,
|
|
164
|
-
backgroundColor: setting.backgroundColor
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return undefined;
|
|
170
|
-
}
|
|
171
|
-
function getTablePanelQueryOptions(spec) {
|
|
172
|
-
// if any cell renders a panel plugin, perform a range query instead of an instant query
|
|
173
|
-
return {
|
|
174
|
-
mode: (spec.columnSettings ?? []).some((c)=>c.plugin) ? 'range' : 'instant'
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function TablePanel({ contentDimensions, spec, queryResults }) {
|
|
178
|
-
// TODO: handle other query types
|
|
179
|
-
const queryMode = getTablePanelQueryOptions(spec).mode;
|
|
180
|
-
const rawData = (0, _react.useMemo)(()=>{
|
|
181
|
-
// Transform query results to a tabular format:
|
|
182
|
-
// [ { timestamp: 123, value: 456, labelName1: labelValue1 }, ... ]
|
|
183
|
-
return queryResults.flatMap((data, queryIndex)=>data.data.series.map((ts)=>({
|
|
184
|
-
data,
|
|
185
|
-
ts,
|
|
186
|
-
queryIndex
|
|
187
|
-
}))).map(({ data, ts, queryIndex })=>{
|
|
188
|
-
if (ts.values[0] === undefined) {
|
|
189
|
-
return {
|
|
190
|
-
...ts.labels
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
// If there are multiple queries, we need to add the query index to the value key and label key to avoid conflicts
|
|
194
|
-
const valueColumnName = queryResults.length === 1 ? 'value' : `value #${queryIndex + 1}`;
|
|
195
|
-
const labels = queryResults.length === 1 ? ts.labels : Object.entries(ts.labels ?? {}).reduce((acc, [key, value])=>{
|
|
196
|
-
if (key) acc[`${key} #${queryIndex + 1}`] = value;
|
|
197
|
-
return acc;
|
|
198
|
-
}, {});
|
|
199
|
-
// If the cell visualization is a panel plugin, filter the data by the current series
|
|
200
|
-
const columnValue = (spec.columnSettings ?? []).find((x)=>x.name === valueColumnName)?.plugin ? {
|
|
201
|
-
...data,
|
|
202
|
-
data: {
|
|
203
|
-
...data.data,
|
|
204
|
-
series: data.data.series.filter((s)=>s === ts)
|
|
205
|
-
}
|
|
206
|
-
} : ts.values[0][1];
|
|
207
|
-
if (queryMode === 'instant') {
|
|
208
|
-
// Timestamp is not indexed as it will be the same for all queries
|
|
209
|
-
return {
|
|
210
|
-
timestamp: ts.values[0][0],
|
|
211
|
-
[valueColumnName]: columnValue,
|
|
212
|
-
...labels
|
|
213
|
-
};
|
|
214
|
-
} else {
|
|
215
|
-
// Don't add a timestamp for range queries
|
|
216
|
-
return {
|
|
217
|
-
[valueColumnName]: columnValue,
|
|
218
|
-
...labels
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}, [
|
|
223
|
-
queryResults,
|
|
224
|
-
queryMode,
|
|
225
|
-
spec.columnSettings
|
|
226
|
-
]);
|
|
227
|
-
// Transform will be applied by their orders on the original data
|
|
228
|
-
const data = (0, _core.useTransformData)(rawData, spec.transforms ?? []);
|
|
229
|
-
const keys = (0, _react.useMemo)(()=>{
|
|
230
|
-
const result = [];
|
|
231
|
-
for (const entry of data){
|
|
232
|
-
for (const key of Object.keys(entry)){
|
|
233
|
-
if (!result.includes(key)) {
|
|
234
|
-
result.push(key);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return result;
|
|
239
|
-
}, [
|
|
240
|
-
data
|
|
241
|
-
]);
|
|
242
|
-
const columns = (0, _react.useMemo)(()=>{
|
|
243
|
-
const columns = [];
|
|
244
|
-
// Taking the customized columns first for the ordering of the columns in the table
|
|
245
|
-
const customizedColumns = spec.columnSettings?.map((column)=>column.name).filter((name)=>keys.includes(name)) ?? [];
|
|
246
|
-
const defaultColumns = keys.filter((key)=>!customizedColumns.includes(key));
|
|
247
|
-
for (const key of customizedColumns){
|
|
248
|
-
const columnConfig = generateColumnConfig(key, spec.columnSettings ?? []);
|
|
249
|
-
if (columnConfig !== undefined) {
|
|
250
|
-
columns.push(columnConfig);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
for (const key of defaultColumns){
|
|
254
|
-
const columnConfig = generateColumnConfig(key, spec.columnSettings ?? []);
|
|
255
|
-
if (columnConfig !== undefined) {
|
|
256
|
-
columns.push(columnConfig);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return columns;
|
|
260
|
-
}, [
|
|
261
|
-
keys,
|
|
262
|
-
spec.columnSettings
|
|
263
|
-
]);
|
|
264
|
-
// Generate cell settings that will be used by the table to render cells (text color, background color, ...)
|
|
265
|
-
const cellConfigs = (0, _react.useMemo)(()=>{
|
|
266
|
-
// If there is no cell settings, return an empty array
|
|
267
|
-
if (spec.cellSettings === undefined) {
|
|
268
|
-
return {};
|
|
269
|
-
}
|
|
270
|
-
const result = {};
|
|
271
|
-
let index = 0;
|
|
272
|
-
for (const row of data){
|
|
273
|
-
// Transforming key to object to extend the row with undefined values if the key is not present
|
|
274
|
-
// for checking the cell config "Misc" condition with "null"
|
|
275
|
-
const keysAsObj = keys.reduce((acc, key)=>{
|
|
276
|
-
acc[key] = undefined;
|
|
277
|
-
return acc;
|
|
278
|
-
}, {});
|
|
279
|
-
const extendRow = {
|
|
280
|
-
...keysAsObj,
|
|
281
|
-
...row
|
|
282
|
-
};
|
|
283
|
-
for (const [key, value] of Object.entries(extendRow)){
|
|
284
|
-
const cellConfig = generateCellConfig(value, spec.cellSettings ?? []);
|
|
285
|
-
if (cellConfig) {
|
|
286
|
-
result[`${index}_${key}`] = cellConfig;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
index++;
|
|
290
|
-
}
|
|
291
|
-
return result;
|
|
292
|
-
}, [
|
|
293
|
-
data,
|
|
294
|
-
keys,
|
|
295
|
-
spec.cellSettings
|
|
296
|
-
]);
|
|
297
|
-
function generateDefaultSortingState() {
|
|
298
|
-
return spec.columnSettings?.filter((column)=>column.sort !== undefined).map((column)=>{
|
|
299
|
-
return {
|
|
300
|
-
id: column.name,
|
|
301
|
-
desc: column.sort === 'desc'
|
|
302
|
-
};
|
|
303
|
-
}) ?? [];
|
|
304
|
-
}
|
|
305
|
-
const [sorting, setSorting] = (0, _react.useState)(generateDefaultSortingState());
|
|
306
|
-
const [pagination, setPagination] = (0, _react.useState)(spec.pagination ? {
|
|
307
|
-
pageIndex: 0,
|
|
308
|
-
pageSize: 10
|
|
309
|
-
} : undefined);
|
|
310
|
-
(0, _react.useEffect)(()=>{
|
|
311
|
-
// If the pagination setting changes from no pagination to pagination, but the pagination state is undefined, update the pagination state
|
|
312
|
-
if (spec.pagination && !pagination) {
|
|
313
|
-
setPagination({
|
|
314
|
-
pageIndex: 0,
|
|
315
|
-
pageSize: 10
|
|
316
|
-
});
|
|
317
|
-
} else if (!spec.pagination && pagination) {
|
|
318
|
-
setPagination(undefined);
|
|
319
|
-
}
|
|
320
|
-
}, [
|
|
321
|
-
spec.pagination,
|
|
322
|
-
pagination
|
|
323
|
-
]);
|
|
324
|
-
if (contentDimensions === undefined) {
|
|
325
|
-
return null;
|
|
326
|
-
}
|
|
327
|
-
return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.Table, {
|
|
328
|
-
data: data,
|
|
329
|
-
columns: columns,
|
|
330
|
-
cellConfigs: cellConfigs,
|
|
331
|
-
height: contentDimensions.height,
|
|
332
|
-
width: contentDimensions.width,
|
|
333
|
-
density: spec.density,
|
|
334
|
-
defaultColumnWidth: spec.defaultColumnWidth,
|
|
335
|
-
defaultColumnHeight: spec.defaultColumnHeight,
|
|
336
|
-
sorting: sorting,
|
|
337
|
-
onSortingChange: setSorting,
|
|
338
|
-
pagination: pagination,
|
|
339
|
-
onPaginationChange: setPagination
|
|
340
|
-
});
|
|
341
|
-
}
|
package/lib/cjs/model.js
DELETED
package/lib/model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,UAAU,sBAAsB;CAAG;AAEnC,MAAM,MAAM,oBAAoB,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC"}
|
package/lib/model.js
DELETED
package/lib/model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model.ts"],"sourcesContent":["import { PanelProps } from '@perses-dev/plugin-system';\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\ninterface TimeSeriesTableOptions {}\n\nexport type TimeSeriesTableProps = PanelProps<TimeSeriesTableOptions>;\n"],"names":[],"mappings":"AAKA,WAAsE"}
|
package/lib/table-model.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"table-model.d.ts","sourceRoot":"","sources":["../../src/table-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IAGb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAEjC,8DAA8D;IAC9D,MAAM,CAAC,EAAE,aAAa,CAAC;IAGvB,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAGpC,aAAa,CAAC,EAAE,OAAO,CAAC;IAGxB,IAAI,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAEtB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAExB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;KACpD,CAAC;CACH;AAED,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,cAAc,GAAG,cAAc,GAAG,aAAa,CAAC;AAEzF,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,IAAI,MAAM,EAAE,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,UAAU,CAAC,YAAY,CAAC;IAC/D,IAAI,EAAE,OAAO,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAE3B,OAAO,CAAC,EAAE,YAAY,CAAC;IAGvB,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAGrC,mBAAmB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEtC,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,cAAc,CAAC,EAAE,cAAc,EAAE,CAAC;IAElC,YAAY,CAAC,EAAE,YAAY,EAAE,CAAC;IAE9B,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,YAAY,CAIxD;AAED,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC"}
|
package/lib/table-model.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/table-model.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, FormatOptions, Transform, UnknownSpec } from '@perses-dev/core';\nimport { TableDensity } from '@perses-dev/components';\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\n\nexport interface ColumnSettings {\n name: string;\n\n // Text to display in the header for the column.\n header?: string;\n /**\n * Text to display when hovering over the header text. This can be useful for\n * providing additional information about the column when you want to keep the\n * header text relatively short to manage the column width.\n */\n headerDescription?: string;\n /**\n * Text to display when hovering over a cell. This can be useful for\n * providing additional information about the column when the content is\n * ellipsized to fit in the space.\n */\n cellDescription?: string;\n\n /**\n * Panel plugin to render.\n * By default, the cells are rendered as text.\n */\n plugin?: Definition<UnknownSpec>;\n\n /** Formatting options. Only applicable if plugin is unset. */\n format?: FormatOptions;\n\n // Alignment of the content in the cell.\n align?: 'left' | 'center' | 'right';\n\n // When `true`, the column will be sortable.\n enableSorting?: boolean;\n\n // Default sort order for the column.\n sort?: 'asc' | 'desc';\n\n /**\n * Width of the column when rendered in a table. It should be a number in pixels\n * or \"auto\" to allow the table to automatically adjust the width to fill\n * space.\n */\n width?: number | 'auto';\n // When `true`, the column will not be displayed.\n hide?: boolean;\n}\n\nexport interface ValueCondition {\n kind: 'Value';\n spec: {\n value: string;\n };\n}\n\nexport interface RangeCondition {\n kind: 'Range';\n spec: {\n min?: number;\n max?: number;\n };\n}\n\nexport interface RegexCondition {\n kind: 'Regex';\n spec: {\n expr: string;\n };\n}\n\nexport interface MiscCondition {\n kind: 'Misc';\n spec: {\n value: 'empty' | 'null' | 'NaN' | 'true' | 'false';\n };\n}\n\nexport type Condition = ValueCondition | RangeCondition | RegexCondition | MiscCondition;\n\nexport interface CellSettings {\n condition: Condition;\n text?: string;\n textColor?: `#${string}`;\n backgroundColor?: `#${string}`;\n}\n\n/**\n * The schema for a Table panel.\n */\nexport interface TableDefinition extends Definition<TableOptions> {\n kind: 'Table';\n}\n\n/**\n * The Options object type supported by the Table panel plugin.\n */\nexport interface TableOptions {\n // Change row height.\n density?: TableDensity;\n // When set to 'auto', the table will try to automatically adjust the width of columns to fit without overflowing.\n // Only for column without custom width specified in columnSettings.\n defaultColumnWidth?: 'auto' | number;\n // When set to 'auto', the table will calculate the cell height based on the line height of the theme and the density setting of the table.\n // Only for column without custom height specified in columnSettings.\n defaultColumnHeight?: 'auto' | number;\n // Enable pagination.\n pagination?: boolean;\n // Customize column display and order them by their index in the array.\n columnSettings?: ColumnSettings[];\n // Customize cell display based on their value.\n cellSettings?: CellSettings[];\n // Apply transforms to the data before rendering the table.\n transforms?: Transform[];\n}\n\n/**\n * Creates the initial/empty options for a Table panel.\n */\nexport function createInitialTableOptions(): TableOptions {\n return {\n density: 'standard',\n };\n}\n\nexport type TableSettingsEditorProps = OptionsEditorProps<TableOptions>;\n"],"names":["createInitialTableOptions","density"],"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;AAuHjC;;CAEC,GACD,OAAO,SAASA;IACd,OAAO;QACLC,SAAS;IACX;AACF"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|