@perses-dev/components 0.55.0-rc.1 → 0.56.0-beta.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/dist/AlignSelector/AlignSelector.js +115 -25
- package/dist/AlignSelector/AlignSelector.js.map +1 -1
- package/dist/CodeEditor/CodeEditor.d.ts +19 -0
- package/dist/CodeEditor/CodeEditor.d.ts.map +1 -0
- package/dist/CodeEditor/CodeEditor.js +122 -0
- package/dist/CodeEditor/CodeEditor.js.map +1 -0
- package/dist/ColorPicker/ColorPicker.js +153 -61
- package/dist/ColorPicker/ColorPicker.js.map +1 -1
- package/dist/ColorPicker/OptionsColorPicker.js +147 -52
- package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
- package/dist/ContentWithLegend/ContentWithLegend.js +144 -41
- package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
- package/dist/DensitySelector/DensitySelector.js +53 -20
- package/dist/DensitySelector/DensitySelector.js.map +1 -1
- package/dist/Dialog/Dialog.d.ts +3 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +202 -49
- package/dist/Dialog/Dialog.js.map +1 -1
- package/dist/Dialog/DiscardChangesConfirmationDialog.js +79 -27
- package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
- package/dist/DragAndDrop/DragAndDropList.js +184 -113
- package/dist/DragAndDrop/DragAndDropList.js.map +1 -1
- package/dist/DragAndDrop/DragButton.js +131 -52
- package/dist/DragAndDrop/DragButton.js.map +1 -1
- package/dist/DragAndDrop/DropIndicator.js +51 -26
- package/dist/DragAndDrop/DropIndicator.js.map +1 -1
- package/dist/Drawer/Drawer.js +75 -15
- package/dist/Drawer/Drawer.js.map +1 -1
- package/dist/EChart/EChart.js +179 -90
- package/dist/EChart/EChart.js.map +1 -1
- package/dist/ErrorAlert.js +14 -4
- package/dist/ErrorAlert.js.map +1 -1
- package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js +463 -190
- package/dist/ExemplarMetadata/ExemplarMetadataTooltip.js.map +1 -1
- package/dist/FontSizeSelector/FontSizeSelector.js +82 -50
- package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
- package/dist/FormEditor/FormActions.js +88 -14
- package/dist/FormEditor/FormActions.js.map +1 -1
- package/dist/FormatControls/FormatControls.js +246 -99
- package/dist/FormatControls/FormatControls.js.map +1 -1
- package/dist/FormatControls/UnitSelector.js +90 -25
- package/dist/FormatControls/UnitSelector.js.map +1 -1
- package/dist/InfoTooltip/InfoTooltip.js +105 -42
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
- package/dist/JSONEditor.d.ts +2 -6
- package/dist/JSONEditor.d.ts.map +1 -1
- package/dist/JSONEditor.js +24 -37
- package/dist/JSONEditor.js.map +1 -1
- package/dist/Legend/CompactLegend.js +77 -27
- package/dist/Legend/CompactLegend.js.map +1 -1
- package/dist/Legend/Legend.js +184 -82
- package/dist/Legend/Legend.js.map +1 -1
- package/dist/Legend/LegendColorBadge.js +54 -9
- package/dist/Legend/LegendColorBadge.js.map +1 -1
- package/dist/Legend/ListLegend.js +46 -16
- package/dist/Legend/ListLegend.js.map +1 -1
- package/dist/Legend/ListLegendItem.js +184 -48
- package/dist/Legend/ListLegendItem.js.map +1 -1
- package/dist/Legend/TableLegend.d.ts.map +1 -1
- package/dist/Legend/TableLegend.js +90 -48
- package/dist/Legend/TableLegend.js.map +1 -1
- package/dist/Legend/legend-model.d.ts +2 -2
- package/dist/Legend/legend-model.d.ts.map +1 -1
- package/dist/Legend/legend-model.js.map +1 -1
- package/dist/LinksEditor/LinkEditorForm.js +148 -67
- package/dist/LinksEditor/LinkEditorForm.js.map +1 -1
- package/dist/ModeSelector/ModeSelector.js +61 -19
- package/dist/ModeSelector/ModeSelector.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js +20 -9
- package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorControl.js +130 -54
- package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js +17 -6
- package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js +76 -28
- package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
- package/dist/Overlay/Overlay.js +71 -27
- package/dist/Overlay/Overlay.js.map +1 -1
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js +96 -38
- package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
- package/dist/RepeatGrid/RepeatGrid.js +117 -45
- package/dist/RepeatGrid/RepeatGrid.js.map +1 -1
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js +99 -38
- package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
- package/dist/SortSelector/SortSelector.js +51 -18
- package/dist/SortSelector/SortSelector.js.map +1 -1
- package/dist/SortSelector/SortSelectorButtons.js +109 -25
- package/dist/SortSelector/SortSelectorButtons.js.map +1 -1
- package/dist/Table/InnerTable.js +46 -15
- package/dist/Table/InnerTable.js.map +1 -1
- package/dist/Table/Table.d.ts +3 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/Table.js +410 -158
- package/dist/Table/Table.js.map +1 -1
- package/dist/Table/TableBody.js +15 -4
- package/dist/Table/TableBody.js.map +1 -1
- package/dist/Table/TableCell.js +284 -107
- package/dist/Table/TableCell.js.map +1 -1
- package/dist/Table/TableCheckbox.js +101 -32
- package/dist/Table/TableCheckbox.js.map +1 -1
- package/dist/Table/TableFoot.js +15 -4
- package/dist/Table/TableFoot.js.map +1 -1
- package/dist/Table/TableHead.js +15 -4
- package/dist/Table/TableHead.js.map +1 -1
- package/dist/Table/TableHeaderCell.js +119 -62
- package/dist/Table/TableHeaderCell.js.map +1 -1
- package/dist/Table/TableRow.js +33 -9
- package/dist/Table/TableRow.js.map +1 -1
- package/dist/Table/TableToolbar.d.ts +5 -4
- package/dist/Table/TableToolbar.d.ts.map +1 -1
- package/dist/Table/TableToolbar.js +172 -100
- package/dist/Table/TableToolbar.js.map +1 -1
- package/dist/Table/VirtualizedTable.d.ts +11 -11
- package/dist/Table/VirtualizedTable.d.ts.map +1 -1
- package/dist/Table/VirtualizedTable.js +387 -219
- package/dist/Table/VirtualizedTable.js.map +1 -1
- package/dist/Table/VirtualizedTableContainer.js +27 -7
- package/dist/Table/VirtualizedTableContainer.js.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.d.ts +6 -5
- package/dist/Table/hooks/useFuzzySearch.d.ts.map +1 -1
- package/dist/Table/hooks/useFuzzySearch.js +57 -32
- package/dist/Table/hooks/useFuzzySearch.js.map +1 -1
- package/dist/Table/hooks/useTableKeyboardNav.js +115 -74
- package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.d.ts.map +1 -1
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +74 -53
- package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
- package/dist/Table/model/table-model.d.ts +44 -15
- package/dist/Table/model/table-model.d.ts.map +1 -1
- package/dist/Table/model/table-model.js +33 -1
- package/dist/Table/model/table-model.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdInput.js +137 -47
- package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
- package/dist/ThresholdsEditor/ThresholdsEditor.js +341 -174
- package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
- package/dist/TimeRangeSelector/DateTimeRangePicker.js +368 -162
- package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js +580 -209
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesInfo.js +189 -65
- package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js +168 -78
- package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
- package/dist/TimeSeriesTooltip/SeriesMarker.js +38 -11
- package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js +229 -72
- package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipContent.js +73 -27
- package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
- package/dist/TimeSeriesTooltip/TooltipHeader.js +221 -121
- package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
- package/dist/TimeSeriesTooltip/tooltip-model.js +44 -38
- package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
- package/dist/TimeZoneSelector.js +131 -36
- package/dist/TimeZoneSelector.js.map +1 -1
- package/dist/ToolbarIconButton/ToolbarIconButton.js +18 -7
- package/dist/ToolbarIconButton/ToolbarIconButton.js.map +1 -1
- package/dist/TransformsEditor/TransformEditor.js +830 -334
- package/dist/TransformsEditor/TransformEditor.js.map +1 -1
- package/dist/TransformsEditor/TransformEditorContainer.js +252 -90
- package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
- package/dist/TransformsEditor/TransformsEditor.js +170 -59
- package/dist/TransformsEditor/TransformsEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingEditor.js +800 -322
- package/dist/ValueMappingEditor/ValueMappingEditor.js.map +1 -1
- package/dist/ValueMappingEditor/ValueMappingsEditor.js +218 -91
- package/dist/ValueMappingEditor/ValueMappingsEditor.js.map +1 -1
- package/dist/YAMLEditor/YAMLEditor.d.ts +12 -0
- package/dist/YAMLEditor/YAMLEditor.d.ts.map +1 -0
- package/dist/YAMLEditor/YAMLEditor.js +41 -0
- package/dist/YAMLEditor/YAMLEditor.js.map +1 -0
- package/dist/YAMLEditor/index.d.ts +2 -0
- package/dist/YAMLEditor/index.d.ts.map +1 -0
- package/dist/YAMLEditor/index.js +15 -0
- package/dist/YAMLEditor/index.js.map +1 -0
- package/dist/YAMLEditor/yaml-utils.d.ts +11 -0
- package/dist/YAMLEditor/yaml-utils.d.ts.map +1 -0
- package/dist/YAMLEditor/yaml-utils.js +52 -0
- package/dist/YAMLEditor/yaml-utils.js.map +1 -0
- package/dist/YAxisLabel.js +64 -20
- package/dist/YAxisLabel.js.map +1 -1
- package/dist/context/ChartsProvider.js +32 -16
- package/dist/context/ChartsProvider.js.map +1 -1
- package/dist/context/ItemActionsProvider.js +110 -61
- package/dist/context/ItemActionsProvider.js.map +1 -1
- package/dist/context/SelectionProvider.js +170 -66
- package/dist/context/SelectionProvider.js.map +1 -1
- package/dist/context/SnackbarProvider.js +101 -44
- package/dist/context/SnackbarProvider.js.map +1 -1
- package/dist/context/TimeZoneProvider.js +35 -14
- package/dist/context/TimeZoneProvider.js.map +1 -1
- package/dist/controls/TextField.js +86 -25
- package/dist/controls/TextField.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/browser-storage.js +64 -34
- package/dist/utils/browser-storage.js.map +1 -1
- package/dist/utils/time-series-data.d.ts.map +1 -1
- package/dist/utils/time-series-data.js +5 -2
- package/dist/utils/time-series-data.js.map +1 -1
- package/package.json +13 -7
|
@@ -11,67 +11,203 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { c as _c } from "react-compiler-runtime";
|
|
14
15
|
import { Box, ListItemText, ListItemButton } from "@mui/material";
|
|
15
16
|
import { forwardRef, memo, useState } from "react";
|
|
16
17
|
import { combineSx } from "../utils/index.js";
|
|
17
18
|
import { LegendColorBadge } from "./LegendColorBadge.js";
|
|
18
|
-
const ListLegendItemBase = /*#__PURE__*/ forwardRef(function ListLegendItem(
|
|
19
|
+
const ListLegendItemBase = /*#__PURE__*/ forwardRef(function ListLegendItem(t0, ref) {
|
|
20
|
+
const $ = _c(47);
|
|
21
|
+
let index;
|
|
22
|
+
let isVisuallySelected;
|
|
23
|
+
let item;
|
|
24
|
+
let onClick;
|
|
25
|
+
let onMouseOut;
|
|
26
|
+
let onMouseOver;
|
|
27
|
+
let others;
|
|
28
|
+
let sx;
|
|
29
|
+
let truncateLabel;
|
|
30
|
+
if ($[0] !== t0) {
|
|
31
|
+
({ item, sx, truncateLabel, onClick, isVisuallySelected, onMouseOver, onMouseOut, index, ...others } = t0);
|
|
32
|
+
$[0] = t0;
|
|
33
|
+
$[1] = index;
|
|
34
|
+
$[2] = isVisuallySelected;
|
|
35
|
+
$[3] = item;
|
|
36
|
+
$[4] = onClick;
|
|
37
|
+
$[5] = onMouseOut;
|
|
38
|
+
$[6] = onMouseOver;
|
|
39
|
+
$[7] = others;
|
|
40
|
+
$[8] = sx;
|
|
41
|
+
$[9] = truncateLabel;
|
|
42
|
+
} else {
|
|
43
|
+
index = $[1];
|
|
44
|
+
isVisuallySelected = $[2];
|
|
45
|
+
item = $[3];
|
|
46
|
+
onClick = $[4];
|
|
47
|
+
onMouseOut = $[5];
|
|
48
|
+
onMouseOver = $[6];
|
|
49
|
+
others = $[7];
|
|
50
|
+
sx = $[8];
|
|
51
|
+
truncateLabel = $[9];
|
|
52
|
+
}
|
|
19
53
|
const [noWrap, setNoWrap] = useState(truncateLabel);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
54
|
+
let t1;
|
|
55
|
+
if ($[10] !== truncateLabel) {
|
|
56
|
+
t1 = function handleTextMouseOver() {
|
|
57
|
+
if (truncateLabel) {
|
|
58
|
+
setNoWrap(false);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
$[10] = truncateLabel;
|
|
62
|
+
$[11] = t1;
|
|
63
|
+
} else {
|
|
64
|
+
t1 = $[11];
|
|
65
|
+
}
|
|
66
|
+
const handleTextMouseOver = t1;
|
|
67
|
+
let t2;
|
|
68
|
+
if ($[12] !== truncateLabel) {
|
|
69
|
+
t2 = function handleTextMouseOut() {
|
|
70
|
+
if (truncateLabel) {
|
|
71
|
+
setNoWrap(true);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
$[12] = truncateLabel;
|
|
75
|
+
$[13] = t2;
|
|
76
|
+
} else {
|
|
77
|
+
t2 = $[13];
|
|
24
78
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
79
|
+
const handleTextMouseOut = t2;
|
|
80
|
+
let t3;
|
|
81
|
+
if ($[14] !== item || $[15] !== onClick) {
|
|
82
|
+
t3 = (e)=>{
|
|
83
|
+
onClick(e, item.id);
|
|
84
|
+
item.onClick?.(e);
|
|
85
|
+
};
|
|
86
|
+
$[14] = item;
|
|
87
|
+
$[15] = onClick;
|
|
88
|
+
$[16] = t3;
|
|
89
|
+
} else {
|
|
90
|
+
t3 = $[16];
|
|
29
91
|
}
|
|
30
|
-
const handleClick =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// ListItemButton must remain the measured and interactive element while exposing its position in the surrounding list.
|
|
35
|
-
/* oxlint-disable jsx-a11y/prefer-tag-over-role */ return /*#__PURE__*/ _jsxs(ListItemButton, {
|
|
36
|
-
...others,
|
|
37
|
-
role: "listitem",
|
|
38
|
-
sx: combineSx({
|
|
92
|
+
const handleClick = t3;
|
|
93
|
+
let t4;
|
|
94
|
+
if ($[17] !== sx) {
|
|
95
|
+
t4 = combineSx({
|
|
39
96
|
padding: 0,
|
|
40
|
-
cursor:
|
|
41
|
-
}, sx)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
97
|
+
cursor: "pointer"
|
|
98
|
+
}, sx);
|
|
99
|
+
$[17] = sx;
|
|
100
|
+
$[18] = t4;
|
|
101
|
+
} else {
|
|
102
|
+
t4 = $[18];
|
|
103
|
+
}
|
|
104
|
+
let t5;
|
|
105
|
+
if ($[19] !== index || $[20] !== item.id || $[21] !== onMouseOver) {
|
|
106
|
+
t5 = (e_0)=>onMouseOver?.(e_0, {
|
|
45
107
|
id: item.id,
|
|
46
108
|
index
|
|
47
|
-
})
|
|
48
|
-
|
|
109
|
+
});
|
|
110
|
+
$[19] = index;
|
|
111
|
+
$[20] = item.id;
|
|
112
|
+
$[21] = onMouseOver;
|
|
113
|
+
$[22] = t5;
|
|
114
|
+
} else {
|
|
115
|
+
t5 = $[22];
|
|
116
|
+
}
|
|
117
|
+
let t6;
|
|
118
|
+
if ($[23] !== index || $[24] !== item.id || $[25] !== onMouseOut) {
|
|
119
|
+
t6 = (e_1)=>onMouseOut?.(e_1, {
|
|
49
120
|
id: item.id,
|
|
50
121
|
index
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
122
|
+
});
|
|
123
|
+
$[23] = index;
|
|
124
|
+
$[24] = item.id;
|
|
125
|
+
$[25] = onMouseOut;
|
|
126
|
+
$[26] = t6;
|
|
127
|
+
} else {
|
|
128
|
+
t6 = $[26];
|
|
129
|
+
}
|
|
130
|
+
let t7;
|
|
131
|
+
if ($[27] === Symbol.for("react.memo_cache_sentinel")) {
|
|
132
|
+
t7 = {
|
|
133
|
+
display: "flex",
|
|
134
|
+
alignItems: "center"
|
|
135
|
+
};
|
|
136
|
+
$[27] = t7;
|
|
137
|
+
} else {
|
|
138
|
+
t7 = $[27];
|
|
139
|
+
}
|
|
140
|
+
let t8;
|
|
141
|
+
if ($[28] !== item.color) {
|
|
142
|
+
t8 = /*#__PURE__*/ _jsx(Box, {
|
|
143
|
+
sx: t7,
|
|
144
|
+
children: /*#__PURE__*/ _jsx(LegendColorBadge, {
|
|
145
|
+
color: item.color
|
|
71
146
|
})
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
147
|
+
});
|
|
148
|
+
$[28] = item.color;
|
|
149
|
+
$[29] = t8;
|
|
150
|
+
} else {
|
|
151
|
+
t8 = $[29];
|
|
152
|
+
}
|
|
153
|
+
let t9;
|
|
154
|
+
if ($[30] !== noWrap) {
|
|
155
|
+
t9 = {
|
|
156
|
+
noWrap
|
|
157
|
+
};
|
|
158
|
+
$[30] = noWrap;
|
|
159
|
+
$[31] = t9;
|
|
160
|
+
} else {
|
|
161
|
+
t9 = $[31];
|
|
162
|
+
}
|
|
163
|
+
let t10;
|
|
164
|
+
if ($[32] !== handleTextMouseOut || $[33] !== handleTextMouseOver || $[34] !== item.label || $[35] !== t9) {
|
|
165
|
+
t10 = /*#__PURE__*/ _jsx(ListItemText, {
|
|
166
|
+
primary: item.label,
|
|
167
|
+
primaryTypographyProps: t9,
|
|
168
|
+
onMouseOver: handleTextMouseOver,
|
|
169
|
+
onMouseOut: handleTextMouseOut
|
|
170
|
+
});
|
|
171
|
+
$[32] = handleTextMouseOut;
|
|
172
|
+
$[33] = handleTextMouseOver;
|
|
173
|
+
$[34] = item.label;
|
|
174
|
+
$[35] = t9;
|
|
175
|
+
$[36] = t10;
|
|
176
|
+
} else {
|
|
177
|
+
t10 = $[36];
|
|
178
|
+
}
|
|
179
|
+
let t11;
|
|
180
|
+
if ($[37] !== handleClick || $[38] !== isVisuallySelected || $[39] !== others || $[40] !== ref || $[41] !== t10 || $[42] !== t4 || $[43] !== t5 || $[44] !== t6 || $[45] !== t8) {
|
|
181
|
+
t11 = /*#__PURE__*/ _jsxs(ListItemButton, {
|
|
182
|
+
...others,
|
|
183
|
+
role: "listitem",
|
|
184
|
+
sx: t4,
|
|
185
|
+
dense: true,
|
|
186
|
+
onClick: handleClick,
|
|
187
|
+
onMouseOver: t5,
|
|
188
|
+
onMouseOut: t6,
|
|
189
|
+
selected: isVisuallySelected,
|
|
190
|
+
ref: ref,
|
|
191
|
+
children: [
|
|
192
|
+
t8,
|
|
193
|
+
t10
|
|
194
|
+
]
|
|
195
|
+
});
|
|
196
|
+
$[37] = handleClick;
|
|
197
|
+
$[38] = isVisuallySelected;
|
|
198
|
+
$[39] = others;
|
|
199
|
+
$[40] = ref;
|
|
200
|
+
$[41] = t10;
|
|
201
|
+
$[42] = t4;
|
|
202
|
+
$[43] = t5;
|
|
203
|
+
$[44] = t6;
|
|
204
|
+
$[45] = t8;
|
|
205
|
+
$[46] = t11;
|
|
206
|
+
} else {
|
|
207
|
+
t11 = $[46];
|
|
208
|
+
}
|
|
209
|
+
return t11;
|
|
210
|
+
});
|
|
75
211
|
export const ListLegendItem = /*#__PURE__*/ memo(ListLegendItemBase);
|
|
76
212
|
|
|
77
213
|
//# sourceMappingURL=ListLegendItem.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/ListLegendItem.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 type { ListItemProps } from '@mui/material';\nimport { Box, ListItemText, ListItemButton } from '@mui/material';\nimport type { MouseEvent, MouseEventHandler, ReactElement } from 'react';\nimport { forwardRef, memo, useState } from 'react';\n\nimport { combineSx } from '../utils';\nimport type { LegendItem } from './legend-model';\nimport { LegendColorBadge } from './LegendColorBadge';\n\nexport type LegendItemEventOpts = {\n /**\n * Unique identifier for the legend item.\n */\n id: string;\n\n /**\n * Index of the row in the original data.\n */\n index: number;\n};\n\nexport interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick' | 'onMouseOver' | 'onMouseOut'> {\n item: LegendItem;\n\n index: number;\n\n /**\n * When true, the item is rendered differently to visually communicate it is\n * selected.\n */\n isVisuallySelected?: boolean;\n\n onClick: (e: MouseEvent<HTMLElement>, seriesId: string) => void;\n\n onMouseOver?: (e: MouseEvent, opts: LegendItemEventOpts) => void;\n onMouseOut?: (e: MouseEvent, opts: LegendItemEventOpts) => void;\n\n /**\n * When `true`, will keep labels to a single line with overflow ellipsized. The\n * full content will be shown on hover.\n *\n * When `false` or unset, will show the full label.\n */\n truncateLabel?: boolean;\n}\n\nconst ListLegendItemBase = forwardRef<HTMLDivElement, ListLegendItemProps>(function ListLegendItem(\n { item, sx, truncateLabel, onClick, isVisuallySelected, onMouseOver, onMouseOut, index, ...others },\n ref,\n): ReactElement {\n const [noWrap, setNoWrap] = useState(truncateLabel);\n\n function handleTextMouseOver(): void {\n if (truncateLabel) {\n setNoWrap(false);\n }\n }\n\n function handleTextMouseOut(): void {\n if (truncateLabel) {\n setNoWrap(true);\n }\n }\n\n const handleClick: MouseEventHandler<HTMLDivElement> = (e) => {\n onClick(e, item.id);\n item.onClick?.(e);\n };\n\n // ListItemButton must remain the measured and interactive element while exposing its position in the surrounding list.\n /* oxlint-disable jsx-a11y/prefer-tag-over-role */\n return (\n <ListItemButton\n {...others}\n role=\"listitem\"\n sx={combineSx(\n {\n padding: 0,\n cursor: 'pointer',\n },\n sx,\n )}\n dense={true}\n onClick={handleClick}\n onMouseOver={(e: MouseEvent) => onMouseOver?.(e, { id: item.id, index })}\n onMouseOut={(e: MouseEvent) => onMouseOut?.(e, { id: item.id, index })}\n selected={isVisuallySelected}\n ref={ref}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <LegendColorBadge color={item.color} />\n </Box>\n <ListItemText\n primary={item.label}\n primaryTypographyProps={{ noWrap: noWrap }}\n onMouseOver={handleTextMouseOver}\n onMouseOut={handleTextMouseOut}\n ></ListItemText>\n </ListItemButton>\n );\n /* oxlint-enable jsx-a11y/prefer-tag-over-role */\n});\n\nexport const ListLegendItem = memo(ListLegendItemBase);\n"],"names":["Box","ListItemText","ListItemButton","forwardRef","memo","useState","combineSx","LegendColorBadge","ListLegendItemBase","ListLegendItem"
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/ListLegendItem.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 type { ListItemProps } from '@mui/material';\nimport { Box, ListItemText, ListItemButton } from '@mui/material';\nimport type { MouseEvent, MouseEventHandler, ReactElement } from 'react';\nimport { forwardRef, memo, useState } from 'react';\n\nimport { combineSx } from '../utils';\nimport type { LegendItem } from './legend-model';\nimport { LegendColorBadge } from './LegendColorBadge';\n\nexport type LegendItemEventOpts = {\n /**\n * Unique identifier for the legend item.\n */\n id: string;\n\n /**\n * Index of the row in the original data.\n */\n index: number;\n};\n\nexport interface ListLegendItemProps extends Omit<ListItemProps<'div'>, 'onClick' | 'onMouseOver' | 'onMouseOut'> {\n item: LegendItem;\n\n index: number;\n\n /**\n * When true, the item is rendered differently to visually communicate it is\n * selected.\n */\n isVisuallySelected?: boolean;\n\n onClick: (e: MouseEvent<HTMLElement>, seriesId: string) => void;\n\n onMouseOver?: (e: MouseEvent, opts: LegendItemEventOpts) => void;\n onMouseOut?: (e: MouseEvent, opts: LegendItemEventOpts) => void;\n\n /**\n * When `true`, will keep labels to a single line with overflow ellipsized. The\n * full content will be shown on hover.\n *\n * When `false` or unset, will show the full label.\n */\n truncateLabel?: boolean;\n}\n\nconst ListLegendItemBase = forwardRef<HTMLDivElement, ListLegendItemProps>(function ListLegendItem(\n { item, sx, truncateLabel, onClick, isVisuallySelected, onMouseOver, onMouseOut, index, ...others },\n ref,\n): ReactElement {\n const [noWrap, setNoWrap] = useState(truncateLabel);\n\n function handleTextMouseOver(): void {\n if (truncateLabel) {\n setNoWrap(false);\n }\n }\n\n function handleTextMouseOut(): void {\n if (truncateLabel) {\n setNoWrap(true);\n }\n }\n\n const handleClick: MouseEventHandler<HTMLDivElement> = (e) => {\n onClick(e, item.id);\n item.onClick?.(e);\n };\n\n // ListItemButton must remain the measured and interactive element while exposing its position in the surrounding list.\n /* oxlint-disable jsx-a11y/prefer-tag-over-role */\n return (\n <ListItemButton\n {...others}\n role=\"listitem\"\n sx={combineSx(\n {\n padding: 0,\n cursor: 'pointer',\n },\n sx,\n )}\n dense={true}\n onClick={handleClick}\n onMouseOver={(e: MouseEvent) => onMouseOver?.(e, { id: item.id, index })}\n onMouseOut={(e: MouseEvent) => onMouseOut?.(e, { id: item.id, index })}\n selected={isVisuallySelected}\n ref={ref}\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <LegendColorBadge color={item.color} />\n </Box>\n <ListItemText\n primary={item.label}\n primaryTypographyProps={{ noWrap: noWrap }}\n onMouseOver={handleTextMouseOver}\n onMouseOut={handleTextMouseOut}\n ></ListItemText>\n </ListItemButton>\n );\n /* oxlint-enable jsx-a11y/prefer-tag-over-role */\n});\n\nexport const ListLegendItem = memo(ListLegendItemBase);\n"],"names":["Box","ListItemText","ListItemButton","forwardRef","memo","useState","combineSx","LegendColorBadge","ListLegendItemBase","ListLegendItem"],"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;;;AAGjC,SAASA,GAAG,EAAEC,YAAY,EAAEC,cAAc,QAAQ,gBAAgB;AAElE,SAASC,UAAU,EAAEC,IAAI,EAAEC,QAAQ,QAAQ,QAAQ;AAEnD,SAASC,SAAS,QAAQ,oBAAW;AAErC,SAASC,gBAAgB,QAAQ,wBAAqB;AAuCtD,MAAMC,mCAAqBL,WAAgD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyD3E,OAAO,MAAMM,+BAAiBL,KAAKI,oBAAoB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/TableLegend.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,UAAU,EAAqB,MAAM,UAAU,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,SAAS,GAAG,iBAAiB,CAAC;IACnG,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC;IAC9D,qBAAqB,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,sBAAsB,CAAC,CAAC;IACtE,eAAe,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC3D,cAAc,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;CAC7C;AA4BD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,aAAa,EAAE,gBAAgB,EAC/B,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,MAAM,EACN,KAAK,EACL,OAAO,EAAE,iBAAiC,EAC1C,OAAO,EACP,eAAe,GAChB,EAAE,gBAAgB,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"TableLegend.d.ts","sourceRoot":"","sources":["../../src/Legend/TableLegend.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,KAAK,EAAE,UAAU,EAAqB,MAAM,UAAU,CAAC;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,SAAS,GAAG,iBAAiB,CAAC;IACnG,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC;IAC9D,qBAAqB,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,sBAAsB,CAAC,CAAC;IACtE,eAAe,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC3D,cAAc,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,eAAe,CAAC,CAAC;IACzD,OAAO,CAAC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC;CAC7C;AA4BD,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,aAAa,EAAE,gBAAgB,EAC/B,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,MAAM,EACN,KAAK,EACL,OAAO,EAAE,iBAAiC,EAC1C,OAAO,EACP,eAAe,GAChB,EAAE,gBAAgB,GAAG,YAAY,CAsDjC"}
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import {
|
|
14
|
+
import { c as _c } from "react-compiler-runtime";
|
|
15
15
|
import { Table, DEFAULT_COLUMN_WIDTH, DEFAULT_COLUMN_MIN_WIDTH } from "../Table/index.js";
|
|
16
16
|
const COLUMNS = [
|
|
17
17
|
{
|
|
18
|
-
accessorKey:
|
|
19
|
-
header:
|
|
18
|
+
accessorKey: "label",
|
|
19
|
+
header: "Name",
|
|
20
20
|
enableSorting: true,
|
|
21
21
|
enableResizing: true,
|
|
22
22
|
// Starting with `title` attr instead of a tooltip because it is easier to
|
|
@@ -37,55 +37,97 @@ const getCheckboxColor = (data)=>{
|
|
|
37
37
|
// This is a rough estimate of value that needs to be subtracted from the total width to avoid horizontal scrolling on initial render
|
|
38
38
|
const TABLE_PADDING = 45;
|
|
39
39
|
const EMPTY_COLUMNS = [];
|
|
40
|
-
export function TableLegend(
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
export function TableLegend(t0) {
|
|
41
|
+
const $ = _c(21);
|
|
42
|
+
const { items, selectedItems: initRowSelection, onSelectedItemsChange, onItemMouseOver, onItemMouseOut, height, width, columns: t1, sorting, onSortingChange } = t0;
|
|
43
|
+
const additionalColumns = t1 === undefined ? EMPTY_COLUMNS : t1;
|
|
44
|
+
let t2;
|
|
45
|
+
if ($[0] !== initRowSelection || $[1] !== items) {
|
|
46
|
+
t2 = typeof initRowSelection !== "string" ? initRowSelection : items.reduce(_temp, {});
|
|
47
|
+
$[0] = initRowSelection;
|
|
48
|
+
$[1] = items;
|
|
49
|
+
$[2] = t2;
|
|
50
|
+
} else {
|
|
51
|
+
t2 = $[2];
|
|
52
|
+
}
|
|
53
|
+
const rowSelection = t2;
|
|
54
|
+
let t3;
|
|
55
|
+
if ($[3] !== additionalColumns) {
|
|
56
|
+
t3 = additionalColumns?.reduce(_temp2, 0) ?? 0;
|
|
57
|
+
$[3] = additionalColumns;
|
|
58
|
+
$[4] = t3;
|
|
59
|
+
} else {
|
|
60
|
+
t3 = $[4];
|
|
61
|
+
}
|
|
62
|
+
const additionalColumnsLength = t3;
|
|
63
|
+
const availableWidth = Math.max(width - additionalColumnsLength - TABLE_PADDING, DEFAULT_COLUMN_MIN_WIDTH * COLUMNS.length);
|
|
64
|
+
const columnWidth = availableWidth / COLUMNS.length;
|
|
65
|
+
let t4;
|
|
66
|
+
if ($[5] !== additionalColumns || $[6] !== columnWidth) {
|
|
67
|
+
let t5;
|
|
68
|
+
if ($[8] !== columnWidth) {
|
|
69
|
+
t5 = (column)=>({
|
|
62
70
|
...column,
|
|
63
71
|
width: columnWidth
|
|
64
|
-
})
|
|
72
|
+
});
|
|
73
|
+
$[8] = columnWidth;
|
|
74
|
+
$[9] = t5;
|
|
75
|
+
} else {
|
|
76
|
+
t5 = $[9];
|
|
77
|
+
}
|
|
78
|
+
t4 = [
|
|
79
|
+
...COLUMNS.map(t5),
|
|
65
80
|
...additionalColumns
|
|
66
81
|
];
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
$[5] = additionalColumns;
|
|
83
|
+
$[6] = columnWidth;
|
|
84
|
+
$[7] = t4;
|
|
85
|
+
} else {
|
|
86
|
+
t4 = $[7];
|
|
87
|
+
}
|
|
88
|
+
const columns = t4;
|
|
89
|
+
let t5;
|
|
90
|
+
if ($[10] !== columns || $[11] !== height || $[12] !== items || $[13] !== onItemMouseOut || $[14] !== onItemMouseOver || $[15] !== onSelectedItemsChange || $[16] !== onSortingChange || $[17] !== rowSelection || $[18] !== sorting || $[19] !== width) {
|
|
91
|
+
t5 = /*#__PURE__*/ _jsx(Table, {
|
|
92
|
+
height: height,
|
|
93
|
+
width: width,
|
|
94
|
+
rowSelection: rowSelection,
|
|
95
|
+
onRowSelectionChange: onSelectedItemsChange,
|
|
96
|
+
onRowMouseOver: onItemMouseOver,
|
|
97
|
+
onRowMouseOut: onItemMouseOut,
|
|
98
|
+
sorting: sorting,
|
|
99
|
+
onSortingChange: onSortingChange,
|
|
100
|
+
data: items,
|
|
101
|
+
columns: columns,
|
|
102
|
+
density: "compact",
|
|
103
|
+
defaultColumnWidth: "auto",
|
|
104
|
+
getRowId: getRowId,
|
|
105
|
+
getCheckboxColor: getCheckboxColor,
|
|
106
|
+
checkboxSelection: true,
|
|
107
|
+
rowSelectionVariant: "legend"
|
|
108
|
+
});
|
|
109
|
+
$[10] = columns;
|
|
110
|
+
$[11] = height;
|
|
111
|
+
$[12] = items;
|
|
112
|
+
$[13] = onItemMouseOut;
|
|
113
|
+
$[14] = onItemMouseOver;
|
|
114
|
+
$[15] = onSelectedItemsChange;
|
|
115
|
+
$[16] = onSortingChange;
|
|
116
|
+
$[17] = rowSelection;
|
|
117
|
+
$[18] = sorting;
|
|
118
|
+
$[19] = width;
|
|
119
|
+
$[20] = t5;
|
|
120
|
+
} else {
|
|
121
|
+
t5 = $[20];
|
|
122
|
+
}
|
|
123
|
+
return t5;
|
|
124
|
+
}
|
|
125
|
+
function _temp2(colWidth, col) {
|
|
126
|
+
return colWidth + (typeof col.width === "number" ? col.width : DEFAULT_COLUMN_WIDTH);
|
|
127
|
+
}
|
|
128
|
+
function _temp(allRowSelection, item, index) {
|
|
129
|
+
allRowSelection[getRowId(item, index)] = true;
|
|
130
|
+
return allRowSelection;
|
|
89
131
|
}
|
|
90
132
|
|
|
91
133
|
//# sourceMappingURL=TableLegend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/TableLegend.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 type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type { TableProps, TableColumnConfig } from '../Table';\nimport { Table, DEFAULT_COLUMN_WIDTH, DEFAULT_COLUMN_MIN_WIDTH } from '../Table';\nimport type { LegendItem } from './legend-model';\n\nexport interface TableLegendProps extends Pick<TableProps<LegendItem>, 'sorting' | 'onSortingChange'> {\n items: LegendItem[];\n height: number;\n width: number;\n selectedItems: TableProps<LegendItem>['rowSelection'] | 'ALL';\n onSelectedItemsChange: TableProps<LegendItem>['onRowSelectionChange'];\n onItemMouseOver?: TableProps<LegendItem>['onRowMouseOver'];\n onItemMouseOut?: TableProps<LegendItem>['onRowMouseOut'];\n columns?: TableProps<LegendItem>['columns'];\n}\n\nconst COLUMNS: Array<TableColumnConfig<LegendItem>> = [\n {\n accessorKey: 'label',\n header: 'Name',\n enableSorting: true,\n enableResizing: true,\n\n // Starting with `title` attr instead of a tooltip because it is easier to\n // implement. We should try adding a tooltip in the future, but we'll need\n // to be very careful about performance when doing so with large tables.\n cell: ({ getValue }) => <span title={getValue<string>()}>{getValue<string>()}</span>,\n },\n];\n\nconst getRowId: NonNullable<TableProps<LegendItem>['getRowId']> = (data) => {\n return data.id;\n};\n\nconst getCheckboxColor: TableProps<LegendItem>['getCheckboxColor'] = (data) => {\n return data.color;\n};\n\n// This is a rough estimate of value that needs to be subtracted from the total width to avoid horizontal scrolling on initial render\nconst TABLE_PADDING = 45;\nconst EMPTY_COLUMNS: Array<TableColumnConfig<LegendItem>> = [];\n\nexport function TableLegend({\n items,\n selectedItems: initRowSelection,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n height,\n width,\n columns: additionalColumns = EMPTY_COLUMNS,\n sorting,\n onSortingChange,\n}: TableLegendProps): ReactElement {\n const rowSelection = useMemo(() => {\n return typeof initRowSelection !== 'string'\n ? initRowSelection\n : // Turn \"ALL\" state into a table component friendly map of all of the selected\n // items for checkboxes.\n // TODO: clean this up if we switch to also using checkboxes in list legend.\n items.reduce(
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/TableLegend.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 type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport type { TableProps, TableColumnConfig } from '../Table';\nimport { Table, DEFAULT_COLUMN_WIDTH, DEFAULT_COLUMN_MIN_WIDTH } from '../Table';\nimport type { LegendItem } from './legend-model';\n\nexport interface TableLegendProps extends Pick<TableProps<LegendItem>, 'sorting' | 'onSortingChange'> {\n items: LegendItem[];\n height: number;\n width: number;\n selectedItems: TableProps<LegendItem>['rowSelection'] | 'ALL';\n onSelectedItemsChange: TableProps<LegendItem>['onRowSelectionChange'];\n onItemMouseOver?: TableProps<LegendItem>['onRowMouseOver'];\n onItemMouseOut?: TableProps<LegendItem>['onRowMouseOut'];\n columns?: TableProps<LegendItem>['columns'];\n}\n\nconst COLUMNS: Array<TableColumnConfig<LegendItem>> = [\n {\n accessorKey: 'label',\n header: 'Name',\n enableSorting: true,\n enableResizing: true,\n\n // Starting with `title` attr instead of a tooltip because it is easier to\n // implement. We should try adding a tooltip in the future, but we'll need\n // to be very careful about performance when doing so with large tables.\n cell: ({ getValue }) => <span title={getValue<string>()}>{getValue<string>()}</span>,\n },\n];\n\nconst getRowId: NonNullable<TableProps<LegendItem>['getRowId']> = (data) => {\n return data.id;\n};\n\nconst getCheckboxColor: TableProps<LegendItem>['getCheckboxColor'] = (data) => {\n return data.color;\n};\n\n// This is a rough estimate of value that needs to be subtracted from the total width to avoid horizontal scrolling on initial render\nconst TABLE_PADDING = 45;\nconst EMPTY_COLUMNS: Array<TableColumnConfig<LegendItem>> = [];\n\nexport function TableLegend({\n items,\n selectedItems: initRowSelection,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n height,\n width,\n columns: additionalColumns = EMPTY_COLUMNS,\n sorting,\n onSortingChange,\n}: TableLegendProps): ReactElement {\n const rowSelection = useMemo(() => {\n return typeof initRowSelection !== 'string'\n ? initRowSelection\n : // Turn \"ALL\" state into a table component friendly map of all of the selected\n // items for checkboxes.\n // TODO: clean this up if we switch to also using checkboxes in list legend.\n items.reduce<Record<string, true>>((allRowSelection, item, index) => {\n allRowSelection[getRowId(item, index)] = true;\n return allRowSelection;\n }, {});\n }, [initRowSelection, items]);\n\n const columns = useMemo(() => {\n // Calculate column widths to fit the container on initial render, avoiding unnecessary horizontal scrolling.\n // Falls back to a default width if available width is too small; the user can resize columns as needed.\n const additionalColumnsLength =\n additionalColumns?.reduce((colWidth, col) => {\n return colWidth + (typeof col.width === 'number' ? col.width : DEFAULT_COLUMN_WIDTH);\n }, 0) ?? 0;\n const availableWidth = Math.max(\n width - additionalColumnsLength - TABLE_PADDING,\n DEFAULT_COLUMN_MIN_WIDTH * COLUMNS.length,\n );\n const columnWidth = availableWidth / COLUMNS.length;\n return [\n ...COLUMNS.map((column) => ({\n ...column,\n width: columnWidth,\n })),\n ...additionalColumns,\n ];\n }, [additionalColumns, width]);\n\n return (\n <Table\n height={height}\n width={width}\n rowSelection={rowSelection}\n onRowSelectionChange={onSelectedItemsChange}\n onRowMouseOver={onItemMouseOver}\n onRowMouseOut={onItemMouseOut}\n sorting={sorting}\n onSortingChange={onSortingChange}\n data={items}\n columns={columns}\n density=\"compact\"\n defaultColumnWidth=\"auto\"\n getRowId={getRowId}\n getCheckboxColor={getCheckboxColor}\n checkboxSelection\n rowSelectionVariant=\"legend\"\n />\n );\n}\n"],"names":["Table","DEFAULT_COLUMN_WIDTH","DEFAULT_COLUMN_MIN_WIDTH","COLUMNS","accessorKey","header","enableSorting","enableResizing","cell","getValue","span","title","getRowId","data","id","getCheckboxColor","color","TABLE_PADDING","EMPTY_COLUMNS"],"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;;;AAMjC,SAASA,KAAK,EAAEC,oBAAoB,EAAEC,wBAAwB,QAAQ,oBAAW;AAcjF,MAAMC,UAAgD;IACpD;QACEC,aAAa;QACbC,QAAQ;QACRC,eAAe;QACfC,gBAAgB;QAEhB,0EAA0E;QAC1E,0EAA0E;QAC1E,wEAAwE;QACxEC,MAAM,CAAC,EAAEC,QAAQ,EAAE,iBAAK,KAACC;gBAAKC,OAAOF;0BAAqBA;;IAC5D;CACD;AAED,MAAMG,WAA4D,CAACC;IACjE,OAAOA,KAAKC,EAAE;AAChB;AAEA,MAAMC,mBAA+D,CAACF;IACpE,OAAOA,KAAKG,KAAK;AACnB;AAEA,qIAAqI;AACrI,MAAMC,gBAAgB;AACtB,MAAMC,gBAAsD,EAAE;AAE9D,OAAO"}
|
|
@@ -15,10 +15,10 @@ export interface LegendItem {
|
|
|
15
15
|
/**
|
|
16
16
|
* State of selected items in the legend.
|
|
17
17
|
* - When "ALL", all legend items are selected, but not visually highlighted.
|
|
18
|
-
* - Otherwise, it is a Record that associates legend item ids with a
|
|
18
|
+
* - Otherwise, it is a Record that associates legend item ids with a `true`
|
|
19
19
|
* value. When the associated entry for a legend item is `true`, that item
|
|
20
20
|
* will be treated as selected and visually highlighted.
|
|
21
21
|
*/
|
|
22
|
-
export type SelectedLegendItemState = Record<LegendItem['id'],
|
|
22
|
+
export type SelectedLegendItemState = Record<LegendItem['id'], true> | 'ALL';
|
|
23
23
|
export declare function isLegendItemVisuallySelected(item: LegendItem, selectedItems: SelectedLegendItemState): boolean;
|
|
24
24
|
//# sourceMappingURL=legend-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legend-model.d.ts","sourceRoot":"","sources":["../../src/Legend/legend-model.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AASlD,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"legend-model.d.ts","sourceRoot":"","sources":["../../src/Legend/legend-model.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AASlD,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B,OAAO,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAC1C;AAED;;;;;;GAMG;AACH,MAAM,MAAM,uBAAuB,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;AAE7E,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,uBAAuB,GAAG,OAAO,CAI9G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/legend-model.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\nimport type { MouseEventHandler } from 'react';\n\nimport type { LegendOptionsBase } from '../model';\n\n// This file contains legend-related model code specific to the legend component.\n// See the `core` package for common/shared legend model code and the\n// `plugin-system` package for legend model code specific to panel plugin specs.\n\n// Note: explicitly defining different options for the legend component and\n// legend spec that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport type LegendComponentOptions = LegendOptionsBase;\n\nexport interface LegendItem {\n id: string;\n label: string;\n color: string;\n\n /**\n * Additional data for the legend item. Useful for laying out additional\n * columns when using a table legend.\n */\n data?: Record<string, unknown>;\n\n onClick?: MouseEventHandler<HTMLElement>;\n}\n\n/**\n * State of selected items in the legend.\n * - When \"ALL\", all legend items are selected, but not visually highlighted.\n * - Otherwise, it is a Record that associates legend item ids with a
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/legend-model.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\nimport type { MouseEventHandler } from 'react';\n\nimport type { LegendOptionsBase } from '../model';\n\n// This file contains legend-related model code specific to the legend component.\n// See the `core` package for common/shared legend model code and the\n// `plugin-system` package for legend model code specific to panel plugin specs.\n\n// Note: explicitly defining different options for the legend component and\n// legend spec that extend from some common options, so we can allow the\n// component and the spec to diverge in some upcoming work.\nexport type LegendComponentOptions = LegendOptionsBase;\n\nexport interface LegendItem {\n id: string;\n label: string;\n color: string;\n\n /**\n * Additional data for the legend item. Useful for laying out additional\n * columns when using a table legend.\n */\n data?: Record<string, unknown>;\n\n onClick?: MouseEventHandler<HTMLElement>;\n}\n\n/**\n * State of selected items in the legend.\n * - When \"ALL\", all legend items are selected, but not visually highlighted.\n * - Otherwise, it is a Record that associates legend item ids with a `true`\n * value. When the associated entry for a legend item is `true`, that item\n * will be treated as selected and visually highlighted.\n */\nexport type SelectedLegendItemState = Record<LegendItem['id'], true> | 'ALL';\n\nexport function isLegendItemVisuallySelected(item: LegendItem, selectedItems: SelectedLegendItemState): boolean {\n // In the \"ALL\" case, technically all legend items are selected, but we do\n // not render them differently.\n return selectedItems !== 'ALL' && !!selectedItems[item.id];\n}\n"],"names":["isLegendItemVisuallySelected","item","selectedItems","id"],"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;AAsCjC,OAAO,SAASA,6BAA6BC,IAAgB,EAAEC,aAAsC;IACnG,0EAA0E;IAC1E,+BAA+B;IAC/B,OAAOA,kBAAkB,SAAS,CAAC,CAACA,aAAa,CAACD,KAAKE,EAAE,CAAC;AAC5D"}
|