@perses-dev/components 0.55.0 → 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/package.json +12 -6
package/dist/Legend/Legend.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { c as _c } from "react-compiler-runtime";
|
|
2
3
|
// Copyright The Perses Authors
|
|
3
4
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
5
|
// you may not use this file except in compliance with the License.
|
|
@@ -23,101 +24,202 @@ import { TableLegend } from "./TableLegend.js";
|
|
|
23
24
|
// Set this number based on testing, but it may need to be tuned a bit on the
|
|
24
25
|
// future as people test this out on different machines.
|
|
25
26
|
const NEED_VIRTUALIZATION_LIMIT = 500;
|
|
26
|
-
export function Legend(
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
export function Legend(t0) {
|
|
28
|
+
const $ = _c(36);
|
|
29
|
+
const { width, height, options, data, selectedItems, onSelectedItemsChange, onItemMouseOver, onItemMouseOut, tableProps } = t0;
|
|
30
|
+
let t1;
|
|
31
|
+
if ($[0] !== onSelectedItemsChange || $[1] !== selectedItems) {
|
|
32
|
+
t1 = (e, seriesId)=>{
|
|
33
|
+
const isModifiedClick = e.metaKey || e.shiftKey;
|
|
34
|
+
const newSelected = produce(selectedItems, (draft)=>{
|
|
35
|
+
if (draft === "ALL") {
|
|
36
|
+
return {
|
|
37
|
+
[seriesId]: true
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const isSelected = !!draft[seriesId];
|
|
41
|
+
if (isModifiedClick) {
|
|
42
|
+
if (isSelected) {
|
|
43
|
+
delete draft[seriesId];
|
|
44
|
+
} else {
|
|
45
|
+
draft[seriesId] = true;
|
|
46
|
+
}
|
|
47
|
+
return draft;
|
|
48
|
+
}
|
|
49
|
+
if (isSelected) {
|
|
50
|
+
return "ALL";
|
|
51
|
+
}
|
|
31
52
|
return {
|
|
32
53
|
[seriesId]: true
|
|
33
54
|
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return draft;
|
|
46
|
-
}
|
|
47
|
-
if (isSelected) {
|
|
48
|
-
// Clicked item was already selected. Unselect it and return to
|
|
49
|
-
// ALL state.
|
|
50
|
-
return 'ALL';
|
|
51
|
-
}
|
|
52
|
-
// Select clicked item.
|
|
53
|
-
return {
|
|
54
|
-
[seriesId]: true
|
|
55
|
-
};
|
|
56
|
-
});
|
|
57
|
-
onSelectedItemsChange(newSelected);
|
|
58
|
-
};
|
|
55
|
+
});
|
|
56
|
+
onSelectedItemsChange(newSelected);
|
|
57
|
+
};
|
|
58
|
+
$[0] = onSelectedItemsChange;
|
|
59
|
+
$[1] = selectedItems;
|
|
60
|
+
$[2] = t1;
|
|
61
|
+
} else {
|
|
62
|
+
t1 = $[2];
|
|
63
|
+
}
|
|
64
|
+
const onLegendItemClick = t1;
|
|
59
65
|
const mode = getLegendMode(options.mode);
|
|
60
|
-
// The bottom legend is displayed as a list when the number of items is too
|
|
61
|
-
// large and requires virtualization. Otherwise, it is rendered more compactly.
|
|
62
|
-
// We do not need this check for the right-side legend because it is always
|
|
63
|
-
// a virtualized list.
|
|
64
66
|
const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
legendContent = /*#__PURE__*/ _jsx(ListLegend, {
|
|
83
|
-
...commonLegendProps,
|
|
84
|
-
width: width,
|
|
85
|
-
onLegendItemClick: onLegendItemClick
|
|
86
|
-
});
|
|
67
|
+
let t2;
|
|
68
|
+
if ($[3] !== data || $[4] !== height || $[5] !== onItemMouseOut || $[6] !== onItemMouseOver || $[7] !== onLegendItemClick || $[8] !== selectedItems) {
|
|
69
|
+
t2 = {
|
|
70
|
+
height,
|
|
71
|
+
items: data,
|
|
72
|
+
selectedItems,
|
|
73
|
+
onLegendItemClick,
|
|
74
|
+
onItemMouseOver,
|
|
75
|
+
onItemMouseOut
|
|
76
|
+
};
|
|
77
|
+
$[3] = data;
|
|
78
|
+
$[4] = height;
|
|
79
|
+
$[5] = onItemMouseOut;
|
|
80
|
+
$[6] = onItemMouseOver;
|
|
81
|
+
$[7] = onLegendItemClick;
|
|
82
|
+
$[8] = selectedItems;
|
|
83
|
+
$[9] = t2;
|
|
87
84
|
} else {
|
|
88
|
-
|
|
89
|
-
...commonLegendProps,
|
|
90
|
-
onLegendItemClick: onLegendItemClick
|
|
91
|
-
});
|
|
85
|
+
t2 = $[9];
|
|
92
86
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
const commonLegendProps = t2;
|
|
88
|
+
let legendContent;
|
|
89
|
+
if (mode === "table") {
|
|
90
|
+
let t3;
|
|
91
|
+
if ($[10] !== commonLegendProps || $[11] !== onSelectedItemsChange || $[12] !== tableProps || $[13] !== width) {
|
|
92
|
+
t3 = /*#__PURE__*/ _jsx(TableLegend, {
|
|
93
|
+
...commonLegendProps,
|
|
94
|
+
onSelectedItemsChange: onSelectedItemsChange,
|
|
96
95
|
width: width,
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
...tableProps
|
|
97
|
+
});
|
|
98
|
+
$[10] = commonLegendProps;
|
|
99
|
+
$[11] = onSelectedItemsChange;
|
|
100
|
+
$[12] = tableProps;
|
|
101
|
+
$[13] = width;
|
|
102
|
+
$[14] = t3;
|
|
103
|
+
} else {
|
|
104
|
+
t3 = $[14];
|
|
105
|
+
}
|
|
106
|
+
legendContent = t3;
|
|
107
|
+
} else {
|
|
108
|
+
if (options.position === "right" || needsVirtualization) {
|
|
109
|
+
let t3;
|
|
110
|
+
if ($[15] !== commonLegendProps || $[16] !== onLegendItemClick || $[17] !== width) {
|
|
111
|
+
t3 = /*#__PURE__*/ _jsx(ListLegend, {
|
|
112
|
+
...commonLegendProps,
|
|
113
|
+
width: width,
|
|
114
|
+
onLegendItemClick: onLegendItemClick
|
|
115
|
+
});
|
|
116
|
+
$[15] = commonLegendProps;
|
|
117
|
+
$[16] = onLegendItemClick;
|
|
118
|
+
$[17] = width;
|
|
119
|
+
$[18] = t3;
|
|
120
|
+
} else {
|
|
121
|
+
t3 = $[18];
|
|
122
|
+
}
|
|
123
|
+
legendContent = t3;
|
|
124
|
+
} else {
|
|
125
|
+
let t3;
|
|
126
|
+
if ($[19] !== commonLegendProps || $[20] !== onLegendItemClick) {
|
|
127
|
+
t3 = /*#__PURE__*/ _jsx(CompactLegend, {
|
|
128
|
+
...commonLegendProps,
|
|
129
|
+
onLegendItemClick: onLegendItemClick
|
|
130
|
+
});
|
|
131
|
+
$[19] = commonLegendProps;
|
|
132
|
+
$[20] = onLegendItemClick;
|
|
133
|
+
$[21] = t3;
|
|
134
|
+
} else {
|
|
135
|
+
t3 = $[21];
|
|
136
|
+
}
|
|
137
|
+
legendContent = t3;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (options.position === "right") {
|
|
141
|
+
let t3;
|
|
142
|
+
if ($[22] !== height || $[23] !== width) {
|
|
143
|
+
t3 = {
|
|
144
|
+
width,
|
|
145
|
+
height
|
|
146
|
+
};
|
|
147
|
+
$[22] = height;
|
|
148
|
+
$[23] = width;
|
|
149
|
+
$[24] = t3;
|
|
150
|
+
} else {
|
|
151
|
+
t3 = $[24];
|
|
152
|
+
}
|
|
153
|
+
let t4;
|
|
154
|
+
if ($[25] === Symbol.for("react.memo_cache_sentinel")) {
|
|
155
|
+
t4 = {
|
|
156
|
+
position: "absolute",
|
|
101
157
|
top: 0,
|
|
102
158
|
right: 0,
|
|
103
|
-
backgroundColor:
|
|
104
|
-
}
|
|
159
|
+
backgroundColor: _temp
|
|
160
|
+
};
|
|
161
|
+
$[25] = t4;
|
|
162
|
+
} else {
|
|
163
|
+
t4 = $[25];
|
|
164
|
+
}
|
|
165
|
+
let t5;
|
|
166
|
+
if ($[26] !== legendContent || $[27] !== t3) {
|
|
167
|
+
t5 = /*#__PURE__*/ _jsx(Box, {
|
|
168
|
+
style: t3,
|
|
169
|
+
sx: t4,
|
|
170
|
+
children: legendContent
|
|
171
|
+
});
|
|
172
|
+
$[26] = legendContent;
|
|
173
|
+
$[27] = t3;
|
|
174
|
+
$[28] = t5;
|
|
175
|
+
} else {
|
|
176
|
+
t5 = $[28];
|
|
177
|
+
}
|
|
178
|
+
return t5;
|
|
179
|
+
}
|
|
180
|
+
let t3;
|
|
181
|
+
if ($[29] !== height || $[30] !== width) {
|
|
182
|
+
t3 = {
|
|
183
|
+
width,
|
|
184
|
+
height
|
|
185
|
+
};
|
|
186
|
+
$[29] = height;
|
|
187
|
+
$[30] = width;
|
|
188
|
+
$[31] = t3;
|
|
189
|
+
} else {
|
|
190
|
+
t3 = $[31];
|
|
191
|
+
}
|
|
192
|
+
let t4;
|
|
193
|
+
if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
|
|
194
|
+
t4 = {
|
|
195
|
+
position: "absolute",
|
|
196
|
+
bottom: 0,
|
|
197
|
+
backgroundColor: _temp2
|
|
198
|
+
};
|
|
199
|
+
$[32] = t4;
|
|
200
|
+
} else {
|
|
201
|
+
t4 = $[32];
|
|
202
|
+
}
|
|
203
|
+
let t5;
|
|
204
|
+
if ($[33] !== legendContent || $[34] !== t3) {
|
|
205
|
+
t5 = /*#__PURE__*/ _jsx(Box, {
|
|
206
|
+
style: t3,
|
|
207
|
+
sx: t4,
|
|
105
208
|
children: legendContent
|
|
106
209
|
});
|
|
210
|
+
$[33] = legendContent;
|
|
211
|
+
$[34] = t3;
|
|
212
|
+
$[35] = t5;
|
|
213
|
+
} else {
|
|
214
|
+
t5 = $[35];
|
|
107
215
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
position: 'absolute',
|
|
116
|
-
bottom: 0,
|
|
117
|
-
backgroundColor: (theme)=>`${theme.palette.background.default}`
|
|
118
|
-
},
|
|
119
|
-
children: legendContent
|
|
120
|
-
});
|
|
216
|
+
return t5;
|
|
217
|
+
}
|
|
218
|
+
function _temp2(theme_0) {
|
|
219
|
+
return `${theme_0.palette.background.default}`;
|
|
220
|
+
}
|
|
221
|
+
function _temp(theme) {
|
|
222
|
+
return `${theme.palette.background.default}`;
|
|
121
223
|
}
|
|
122
224
|
|
|
123
225
|
//# sourceMappingURL=Legend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/Legend.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 { Box } from '@mui/material';\nimport { produce } from 'immer';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { getLegendMode } from '../model';\nimport { CompactLegend } from './CompactLegend';\nimport type { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';\nimport { ListLegend } from './ListLegend';\nimport type { ListLegendItemProps } from './ListLegendItem';\nimport type { TableLegendProps } from './TableLegend';\nimport { TableLegend } from './TableLegend';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendComponentOptions;\n\n /**\n * State of selected items in the legend.\n *\n * Selected legend item state is a controlled value that should be managed using a\n * combination of this prop and `onSelectedChange`.\n */\n selectedItems: SelectedLegendItemState;\n\n /**\n * Callback fired when the selected items in the legend changes.\n */\n onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;\n\n /**\n * Callback fired when the mouse is moved over a legend item.\n */\n onItemMouseOver?: ListLegendItemProps['onMouseOver'];\n\n /**\n * Callback fired when the mouse is moved out of a legend item.\n */\n onItemMouseOut?: ListLegendItemProps['onMouseOut'];\n\n /**\n * Props specific to legend with `mode` set to `table`.\n */\n tableProps?: Pick<TableLegendProps, 'columns' | 'onSortingChange' | 'sorting'>;\n}\n\n// When the number of items to display is above this number, it is likely to\n// cause performance issues in the browser. The legend will be displayed in a\n// format (list) that allows for virtualization to minimize the performance impact.\n// Set this number based on testing, but it may need to be tuned a bit on the\n// future as people test this out on different machines.\nconst NEED_VIRTUALIZATION_LIMIT = 500;\n\nexport function Legend({\n width,\n height,\n options,\n data,\n selectedItems,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n tableProps,\n}: LegendProps): ReactElement {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string): void => {\n const isModifiedClick = e.metaKey || e.shiftKey;\n\n const newSelected = produce(selectedItems, (draft) => {\n if (draft === 'ALL') {\n return {\n [seriesId]: true,\n };\n }\n\n const isSelected = !!draft[seriesId];\n\n // Clicks with modifier key can select multiple items.\n if (isModifiedClick) {\n if (isSelected) {\n // Modified click on already selected item. Remove that item.\n delete draft[seriesId];\n } else {\n // Modified click on not-selected item. Add it.\n draft[seriesId] = true;\n }\n return draft;\n }\n\n if (isSelected) {\n // Clicked item was already selected. Unselect it and return to\n // ALL state.\n return 'ALL' as const;\n }\n\n // Select clicked item.\n return { [seriesId]: true };\n });\n onSelectedItemsChange(newSelected);\n };\n\n const mode = getLegendMode(options.mode);\n\n // The bottom legend is displayed as a list when the number of items is too\n // large and requires virtualization. Otherwise, it is rendered more compactly.\n // We do not need this check for the right-side legend because it is always\n // a virtualized list.\n const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;\n\n const commonLegendProps = {\n height,\n items: data,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n };\n\n let legendContent: ReactNode;\n if (mode === 'table') {\n legendContent = (\n <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} {...tableProps} />\n );\n } else if (options.position === 'right' || needsVirtualization) {\n legendContent = <ListLegend {...commonLegendProps} width={width} onLegendItemClick={onLegendItemClick} />;\n } else {\n legendContent = <CompactLegend {...commonLegendProps} onLegendItemClick={onLegendItemClick} />;\n }\n\n if (options.position === 'right') {\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n top: 0,\n right: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n bottom: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n}\n"],"names":["Box","produce","getLegendMode","CompactLegend","ListLegend","TableLegend","NEED_VIRTUALIZATION_LIMIT"
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/Legend.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 { Box } from '@mui/material';\nimport { produce } from 'immer';\nimport type { ReactElement, ReactNode } from 'react';\n\nimport { getLegendMode } from '../model';\nimport { CompactLegend } from './CompactLegend';\nimport type { LegendItem, LegendComponentOptions, SelectedLegendItemState } from './legend-model';\nimport { ListLegend } from './ListLegend';\nimport type { ListLegendItemProps } from './ListLegendItem';\nimport type { TableLegendProps } from './TableLegend';\nimport { TableLegend } from './TableLegend';\n\nexport interface LegendProps {\n width: number;\n height: number;\n data: LegendItem[];\n options: LegendComponentOptions;\n\n /**\n * State of selected items in the legend.\n *\n * Selected legend item state is a controlled value that should be managed using a\n * combination of this prop and `onSelectedChange`.\n */\n selectedItems: SelectedLegendItemState;\n\n /**\n * Callback fired when the selected items in the legend changes.\n */\n onSelectedItemsChange: (newSelected: SelectedLegendItemState) => void;\n\n /**\n * Callback fired when the mouse is moved over a legend item.\n */\n onItemMouseOver?: ListLegendItemProps['onMouseOver'];\n\n /**\n * Callback fired when the mouse is moved out of a legend item.\n */\n onItemMouseOut?: ListLegendItemProps['onMouseOut'];\n\n /**\n * Props specific to legend with `mode` set to `table`.\n */\n tableProps?: Pick<TableLegendProps, 'columns' | 'onSortingChange' | 'sorting'>;\n}\n\n// When the number of items to display is above this number, it is likely to\n// cause performance issues in the browser. The legend will be displayed in a\n// format (list) that allows for virtualization to minimize the performance impact.\n// Set this number based on testing, but it may need to be tuned a bit on the\n// future as people test this out on different machines.\nconst NEED_VIRTUALIZATION_LIMIT = 500;\n\nexport function Legend({\n width,\n height,\n options,\n data,\n selectedItems,\n onSelectedItemsChange,\n onItemMouseOver,\n onItemMouseOut,\n tableProps,\n}: LegendProps): ReactElement {\n const onLegendItemClick = (e: React.MouseEvent<HTMLElement, MouseEvent>, seriesId: string): void => {\n const isModifiedClick = e.metaKey || e.shiftKey;\n\n const newSelected = produce<SelectedLegendItemState>(selectedItems, (draft) => {\n if (draft === 'ALL') {\n return {\n [seriesId]: true,\n };\n }\n\n const isSelected = !!draft[seriesId];\n\n // Clicks with modifier key can select multiple items.\n if (isModifiedClick) {\n if (isSelected) {\n // Modified click on already selected item. Remove that item.\n delete draft[seriesId];\n } else {\n // Modified click on not-selected item. Add it.\n draft[seriesId] = true;\n }\n return draft;\n }\n\n if (isSelected) {\n // Clicked item was already selected. Unselect it and return to\n // ALL state.\n return 'ALL' as const;\n }\n\n // Select clicked item.\n return { [seriesId]: true };\n });\n onSelectedItemsChange(newSelected);\n };\n\n const mode = getLegendMode(options.mode);\n\n // The bottom legend is displayed as a list when the number of items is too\n // large and requires virtualization. Otherwise, it is rendered more compactly.\n // We do not need this check for the right-side legend because it is always\n // a virtualized list.\n const needsVirtualization = data.length >= NEED_VIRTUALIZATION_LIMIT;\n\n const commonLegendProps = {\n height,\n items: data,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n };\n\n let legendContent: ReactNode;\n if (mode === 'table') {\n legendContent = (\n <TableLegend {...commonLegendProps} onSelectedItemsChange={onSelectedItemsChange} width={width} {...tableProps} />\n );\n } else if (options.position === 'right' || needsVirtualization) {\n legendContent = <ListLegend {...commonLegendProps} width={width} onLegendItemClick={onLegendItemClick} />;\n } else {\n legendContent = <CompactLegend {...commonLegendProps} onLegendItemClick={onLegendItemClick} />;\n }\n\n if (options.position === 'right') {\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n top: 0,\n right: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n }\n\n // Position bottom\n return (\n <Box\n style={{\n width: width,\n height: height,\n }}\n sx={{\n position: 'absolute',\n bottom: 0,\n backgroundColor: (theme) => `${theme.palette.background.default}`,\n }}\n >\n {legendContent}\n </Box>\n );\n}\n"],"names":["Box","produce","getLegendMode","CompactLegend","ListLegend","TableLegend","NEED_VIRTUALIZATION_LIMIT"],"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,GAAG,QAAQ,gBAAgB;AACpC,SAASC,OAAO,QAAQ,QAAQ;AAGhC,SAASC,aAAa,QAAQ,oBAAW;AACzC,SAASC,aAAa,QAAQ,qBAAkB;AAEhD,SAASC,UAAU,QAAQ,kBAAe;AAG1C,SAASC,WAAW,QAAQ,mBAAgB;AAqC5C,4EAA4E;AAC5E,6EAA6E;AAC7E,mFAAmF;AACnF,6EAA6E;AAC7E,wDAAwD;AACxD,MAAMC,4BAA4B;AAElC,OAAO"}
|
|
@@ -11,21 +11,66 @@
|
|
|
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 { c as _c } from "react-compiler-runtime";
|
|
14
15
|
import { Box } from "@mui/material";
|
|
15
16
|
import { memo } from "react";
|
|
16
17
|
import { combineSx } from "../utils/index.js";
|
|
17
|
-
export const LegendColorBadge = /*#__PURE__*/ memo(function LegendColorBadge(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export const LegendColorBadge = /*#__PURE__*/ memo(function LegendColorBadge(t0) {
|
|
19
|
+
const $ = _c(12);
|
|
20
|
+
let color;
|
|
21
|
+
let others;
|
|
22
|
+
let sx;
|
|
23
|
+
if ($[0] !== t0) {
|
|
24
|
+
({ color, sx, ...others } = t0);
|
|
25
|
+
$[0] = t0;
|
|
26
|
+
$[1] = color;
|
|
27
|
+
$[2] = others;
|
|
28
|
+
$[3] = sx;
|
|
29
|
+
} else {
|
|
30
|
+
color = $[1];
|
|
31
|
+
others = $[2];
|
|
32
|
+
sx = $[3];
|
|
33
|
+
}
|
|
34
|
+
let t1;
|
|
35
|
+
if ($[4] !== sx) {
|
|
36
|
+
t1 = combineSx({
|
|
21
37
|
height: 4,
|
|
22
38
|
width: 16,
|
|
23
|
-
margin:
|
|
24
|
-
}, sx)
|
|
25
|
-
|
|
39
|
+
margin: _temp
|
|
40
|
+
}, sx);
|
|
41
|
+
$[4] = sx;
|
|
42
|
+
$[5] = t1;
|
|
43
|
+
} else {
|
|
44
|
+
t1 = $[5];
|
|
45
|
+
}
|
|
46
|
+
let t2;
|
|
47
|
+
if ($[6] !== color) {
|
|
48
|
+
t2 = {
|
|
26
49
|
backgroundColor: color
|
|
27
|
-
}
|
|
28
|
-
|
|
50
|
+
};
|
|
51
|
+
$[6] = color;
|
|
52
|
+
$[7] = t2;
|
|
53
|
+
} else {
|
|
54
|
+
t2 = $[7];
|
|
55
|
+
}
|
|
56
|
+
let t3;
|
|
57
|
+
if ($[8] !== others || $[9] !== t1 || $[10] !== t2) {
|
|
58
|
+
t3 = /*#__PURE__*/ _jsx(Box, {
|
|
59
|
+
...others,
|
|
60
|
+
sx: t1,
|
|
61
|
+
style: t2
|
|
62
|
+
});
|
|
63
|
+
$[8] = others;
|
|
64
|
+
$[9] = t1;
|
|
65
|
+
$[10] = t2;
|
|
66
|
+
$[11] = t3;
|
|
67
|
+
} else {
|
|
68
|
+
t3 = $[11];
|
|
69
|
+
}
|
|
70
|
+
return t3;
|
|
29
71
|
});
|
|
72
|
+
function _temp(theme) {
|
|
73
|
+
return theme.spacing(0.5);
|
|
74
|
+
}
|
|
30
75
|
|
|
31
76
|
//# sourceMappingURL=LegendColorBadge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/LegendColorBadge.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 { BoxProps } from '@mui/material';\nimport { Box } from '@mui/material';\nimport type { ReactElement } from 'react';\nimport { memo } from 'react';\n\nimport { combineSx } from '../utils';\n\nexport interface LegendColorBadgeProps extends BoxProps<'div'> {\n color: string;\n}\n\nexport const LegendColorBadge = memo(function LegendColorBadge({\n color,\n sx,\n ...others\n}: LegendColorBadgeProps): ReactElement {\n return (\n <Box\n {...others}\n sx={combineSx(\n {\n height: 4,\n width: 16,\n margin: (theme) => theme.spacing(0.5),\n },\n sx,\n )}\n style={{ backgroundColor: color }}\n />\n );\n});\n"],"names":["Box","memo","combineSx","LegendColorBadge"
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/LegendColorBadge.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 { BoxProps } from '@mui/material';\nimport { Box } from '@mui/material';\nimport type { ReactElement } from 'react';\nimport { memo } from 'react';\n\nimport { combineSx } from '../utils';\n\nexport interface LegendColorBadgeProps extends BoxProps<'div'> {\n color: string;\n}\n\nexport const LegendColorBadge = memo(function LegendColorBadge({\n color,\n sx,\n ...others\n}: LegendColorBadgeProps): ReactElement {\n return (\n <Box\n {...others}\n sx={combineSx(\n {\n height: 4,\n width: 16,\n margin: (theme) => theme.spacing(0.5),\n },\n sx,\n )}\n style={{ backgroundColor: color }}\n />\n );\n});\n"],"names":["Box","memo","combineSx","LegendColorBadge"],"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,QAAQ,gBAAgB;AAEpC,SAASC,IAAI,QAAQ,QAAQ;AAE7B,SAASC,SAAS,QAAQ,oBAAW;AAMrC,OAAO,MAAMC,iCAAmBF,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmBlC"}
|
|
@@ -11,6 +11,7 @@
|
|
|
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 { c as _c } from "react-compiler-runtime";
|
|
14
15
|
import { Virtuoso } from "react-virtuoso";
|
|
15
16
|
import { isLegendItemVisuallySelected } from "./legend-model.js";
|
|
16
17
|
import { ListLegendItem } from "./ListLegendItem.js";
|
|
@@ -19,18 +20,25 @@ import { ListLegendItem } from "./ListLegendItem.js";
|
|
|
19
20
|
* stacked. It is also used for `bottom` positioned legends when there are a
|
|
20
21
|
* large number of items because it is virtualized and easier to visually scan
|
|
21
22
|
* large numbers of items when there is a single item per row.
|
|
22
|
-
*/ export function ListLegend(
|
|
23
|
-
|
|
23
|
+
*/ export function ListLegend(t0) {
|
|
24
|
+
const $ = _c(13);
|
|
25
|
+
const { items, height, width, selectedItems, onLegendItemClick, onItemMouseOver, onItemMouseOut } = t0;
|
|
24
26
|
const truncateLabels = items.length > 5;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
let t1;
|
|
28
|
+
if ($[0] !== height || $[1] !== width) {
|
|
29
|
+
t1 = {
|
|
28
30
|
height,
|
|
29
31
|
width
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
};
|
|
33
|
+
$[0] = height;
|
|
34
|
+
$[1] = width;
|
|
35
|
+
$[2] = t1;
|
|
36
|
+
} else {
|
|
37
|
+
t1 = $[2];
|
|
38
|
+
}
|
|
39
|
+
let t2;
|
|
40
|
+
if ($[3] !== onItemMouseOut || $[4] !== onItemMouseOver || $[5] !== onLegendItemClick || $[6] !== selectedItems || $[7] !== truncateLabels) {
|
|
41
|
+
t2 = (index, item)=>/*#__PURE__*/ _jsx(ListLegendItem, {
|
|
34
42
|
item: item,
|
|
35
43
|
index: index,
|
|
36
44
|
truncateLabel: truncateLabels,
|
|
@@ -39,14 +47,36 @@ import { ListLegendItem } from "./ListLegendItem.js";
|
|
|
39
47
|
onMouseOver: onItemMouseOver,
|
|
40
48
|
onMouseOut: onItemMouseOut,
|
|
41
49
|
sx: {
|
|
42
|
-
width:
|
|
43
|
-
wordBreak:
|
|
44
|
-
overflow:
|
|
50
|
+
width: "100%",
|
|
51
|
+
wordBreak: "break-word",
|
|
52
|
+
overflow: "hidden"
|
|
45
53
|
}
|
|
46
54
|
}, item.id);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
$[3] = onItemMouseOut;
|
|
56
|
+
$[4] = onItemMouseOver;
|
|
57
|
+
$[5] = onLegendItemClick;
|
|
58
|
+
$[6] = selectedItems;
|
|
59
|
+
$[7] = truncateLabels;
|
|
60
|
+
$[8] = t2;
|
|
61
|
+
} else {
|
|
62
|
+
t2 = $[8];
|
|
63
|
+
}
|
|
64
|
+
let t3;
|
|
65
|
+
if ($[9] !== items || $[10] !== t1 || $[11] !== t2) {
|
|
66
|
+
t3 = /*#__PURE__*/ _jsx(Virtuoso, {
|
|
67
|
+
style: t1,
|
|
68
|
+
data: items,
|
|
69
|
+
itemContent: t2,
|
|
70
|
+
role: "list"
|
|
71
|
+
});
|
|
72
|
+
$[9] = items;
|
|
73
|
+
$[10] = t1;
|
|
74
|
+
$[11] = t2;
|
|
75
|
+
$[12] = t3;
|
|
76
|
+
} else {
|
|
77
|
+
t3 = $[12];
|
|
78
|
+
}
|
|
79
|
+
return t3;
|
|
80
|
+
}
|
|
51
81
|
|
|
52
82
|
//# sourceMappingURL=ListLegend.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Legend/ListLegend.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 { Virtuoso } from 'react-virtuoso';\n\nimport type { LegendItem, SelectedLegendItemState } from './legend-model';\nimport { isLegendItemVisuallySelected } from './legend-model';\nimport type { ListLegendItemProps } from './ListLegendItem';\nimport { ListLegendItem } from './ListLegendItem';\n\nexport interface ListLegendProps {\n items: LegendItem[];\n height: number;\n width: number;\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n onItemMouseOver: ListLegendItemProps['onMouseOver'];\n onItemMouseOut: ListLegendItemProps['onMouseOut'];\n}\n\n/**\n * ListLegend is used when legend.position is 'right' since legend items are\n * stacked. It is also used for `bottom` positioned legends when there are a\n * large number of items because it is virtualized and easier to visually scan\n * large numbers of items when there is a single item per row.\n */\nexport function ListLegend({\n items,\n height,\n width,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n}: ListLegendProps): ReactElement {\n // show full labels on hover when there are many total series\n const truncateLabels = items.length > 5;\n // Virtuoso requires its scroll container to remain a div, so native ul semantics cannot be used here.\n /* oxlint-disable jsx-a11y/prefer-tag-over-role */\n return (\n <Virtuoso\n style={{ height, width }}\n data={items}\n itemContent={(index, item) => {\n return (\n <ListLegendItem\n key={item.id}\n item={item}\n index={index}\n truncateLabel={truncateLabels}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n onMouseOver={onItemMouseOver}\n onMouseOut={onItemMouseOut}\n sx={{\n width: '100%',\n wordBreak: 'break-word',\n overflow: 'hidden',\n }}\n />\n );\n }}\n role=\"list\"\n />\n );\n /* oxlint-enable jsx-a11y/prefer-tag-over-role */\n}\n"],"names":["Virtuoso","isLegendItemVisuallySelected","ListLegendItem"
|
|
1
|
+
{"version":3,"sources":["../../src/Legend/ListLegend.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 { Virtuoso } from 'react-virtuoso';\n\nimport type { LegendItem, SelectedLegendItemState } from './legend-model';\nimport { isLegendItemVisuallySelected } from './legend-model';\nimport type { ListLegendItemProps } from './ListLegendItem';\nimport { ListLegendItem } from './ListLegendItem';\n\nexport interface ListLegendProps {\n items: LegendItem[];\n height: number;\n width: number;\n selectedItems: SelectedLegendItemState;\n onLegendItemClick: ListLegendItemProps['onClick'];\n onItemMouseOver: ListLegendItemProps['onMouseOver'];\n onItemMouseOut: ListLegendItemProps['onMouseOut'];\n}\n\n/**\n * ListLegend is used when legend.position is 'right' since legend items are\n * stacked. It is also used for `bottom` positioned legends when there are a\n * large number of items because it is virtualized and easier to visually scan\n * large numbers of items when there is a single item per row.\n */\nexport function ListLegend({\n items,\n height,\n width,\n selectedItems,\n onLegendItemClick,\n onItemMouseOver,\n onItemMouseOut,\n}: ListLegendProps): ReactElement {\n // show full labels on hover when there are many total series\n const truncateLabels = items.length > 5;\n // Virtuoso requires its scroll container to remain a div, so native ul semantics cannot be used here.\n /* oxlint-disable jsx-a11y/prefer-tag-over-role */\n return (\n <Virtuoso\n style={{ height, width }}\n data={items}\n itemContent={(index, item) => {\n return (\n <ListLegendItem\n key={item.id}\n item={item}\n index={index}\n truncateLabel={truncateLabels}\n isVisuallySelected={isLegendItemVisuallySelected(item, selectedItems)}\n onClick={onLegendItemClick}\n onMouseOver={onItemMouseOver}\n onMouseOut={onItemMouseOut}\n sx={{\n width: '100%',\n wordBreak: 'break-word',\n overflow: 'hidden',\n }}\n />\n );\n }}\n role=\"list\"\n />\n );\n /* oxlint-enable jsx-a11y/prefer-tag-over-role */\n}\n"],"names":["Virtuoso","isLegendItemVisuallySelected","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,QAAQ,QAAQ,iBAAiB;AAG1C,SAASC,4BAA4B,QAAQ,oBAAiB;AAE9D,SAASC,cAAc,QAAQ,sBAAmB;AAYlD;;;;;CAKC,GACD,OAAO"}
|