@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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } 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.
|
|
@@ -17,139 +18,238 @@ import PinOutline from "mdi-material-ui/PinOutline";
|
|
|
17
18
|
import { memo } from "react";
|
|
18
19
|
import { useTimeZone } from "../context/TimeZoneProvider.js";
|
|
19
20
|
import { TOOLTIP_BG_COLOR_FALLBACK, TOOLTIP_MAX_WIDTH, PIN_TOOLTIP_HELP_TEXT, UNPIN_TOOLTIP_HELP_TEXT } from "./tooltip-model.js";
|
|
20
|
-
export const TooltipHeader = /*#__PURE__*/ memo(function TooltipHeader(
|
|
21
|
+
export const TooltipHeader = /*#__PURE__*/ memo(function TooltipHeader(t0) {
|
|
22
|
+
const $ = _c(25);
|
|
23
|
+
const { nearbySeries, totalSeries, isTooltipPinned, showAllSeries, enablePinning: t1, onShowAllClick, onUnpinClick } = t0;
|
|
24
|
+
const enablePinning = t1 === undefined ? true : t1;
|
|
21
25
|
const { formatWithUserTimeZone } = useTimeZone();
|
|
22
26
|
const seriesTimeMs = nearbySeries[0]?.date ?? null;
|
|
23
27
|
if (seriesTimeMs === null) {
|
|
24
28
|
return null;
|
|
25
29
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
let t2;
|
|
31
|
+
if ($[0] !== formatWithUserTimeZone) {
|
|
32
|
+
t2 = (timeMs)=>{
|
|
33
|
+
const date = new Date(timeMs);
|
|
34
|
+
const formattedDate = formatWithUserTimeZone(date, "MMM dd, yyyy - ");
|
|
35
|
+
const formattedTime = formatWithUserTimeZone(date, "HH:mm:ss");
|
|
36
|
+
return /*#__PURE__*/ _jsxs(Box, {
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
39
|
+
variant: "caption",
|
|
40
|
+
sx: _temp,
|
|
41
|
+
children: formattedDate
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
44
|
+
variant: "caption",
|
|
45
|
+
children: /*#__PURE__*/ _jsx("strong", {
|
|
46
|
+
children: formattedTime
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
]
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
$[0] = formatWithUserTimeZone;
|
|
53
|
+
$[1] = t2;
|
|
54
|
+
} else {
|
|
55
|
+
t2 = $[1];
|
|
56
|
+
}
|
|
57
|
+
const formatTimeSeriesHeader = t2;
|
|
58
|
+
const showAllSeriesToggle = enablePinning && totalSeries > 5;
|
|
59
|
+
const pinTooltipHelpText = isTooltipPinned ? UNPIN_TOOLTIP_HELP_TEXT : PIN_TOOLTIP_HELP_TEXT;
|
|
60
|
+
let t3;
|
|
61
|
+
if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
|
|
62
|
+
t3 = {
|
|
63
|
+
width: "100%",
|
|
64
|
+
display: "flex",
|
|
65
|
+
justifyContent: "start",
|
|
66
|
+
alignItems: "center",
|
|
67
|
+
paddingBottom: 0.5
|
|
68
|
+
};
|
|
69
|
+
$[2] = t3;
|
|
70
|
+
} else {
|
|
71
|
+
t3 = $[2];
|
|
72
|
+
}
|
|
73
|
+
let t4;
|
|
74
|
+
if ($[3] !== formatTimeSeriesHeader || $[4] !== seriesTimeMs) {
|
|
75
|
+
t4 = formatTimeSeriesHeader(seriesTimeMs);
|
|
76
|
+
$[3] = formatTimeSeriesHeader;
|
|
77
|
+
$[4] = seriesTimeMs;
|
|
78
|
+
$[5] = t4;
|
|
79
|
+
} else {
|
|
80
|
+
t4 = $[5];
|
|
81
|
+
}
|
|
82
|
+
let t5;
|
|
83
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
84
|
+
t5 = {
|
|
85
|
+
marginLeft: "auto"
|
|
86
|
+
};
|
|
87
|
+
$[6] = t5;
|
|
88
|
+
} else {
|
|
89
|
+
t5 = $[6];
|
|
90
|
+
}
|
|
91
|
+
let t6;
|
|
92
|
+
if ($[7] !== onShowAllClick || $[8] !== showAllSeries || $[9] !== showAllSeriesToggle) {
|
|
93
|
+
t6 = showAllSeriesToggle && /*#__PURE__*/ _jsxs(Stack, {
|
|
94
|
+
direction: "row",
|
|
95
|
+
gap: 0.5,
|
|
96
|
+
alignItems: "center",
|
|
97
|
+
sx: {
|
|
98
|
+
textAlign: "right"
|
|
99
|
+
},
|
|
31
100
|
children: [
|
|
32
101
|
/*#__PURE__*/ _jsx(Typography, {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
children: formattedDate
|
|
102
|
+
sx: {
|
|
103
|
+
fontSize: 11
|
|
104
|
+
},
|
|
105
|
+
children: "Show All"
|
|
38
106
|
}),
|
|
107
|
+
/*#__PURE__*/ _jsx(Switch, {
|
|
108
|
+
checked: showAllSeries,
|
|
109
|
+
size: "small",
|
|
110
|
+
onChange: (_, checked)=>{
|
|
111
|
+
if (onShowAllClick !== undefined) {
|
|
112
|
+
return onShowAllClick(checked);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
sx: _temp3
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
$[7] = onShowAllClick;
|
|
120
|
+
$[8] = showAllSeries;
|
|
121
|
+
$[9] = showAllSeriesToggle;
|
|
122
|
+
$[10] = t6;
|
|
123
|
+
} else {
|
|
124
|
+
t6 = $[10];
|
|
125
|
+
}
|
|
126
|
+
let t7;
|
|
127
|
+
if ($[11] !== enablePinning || $[12] !== isTooltipPinned || $[13] !== onUnpinClick || $[14] !== pinTooltipHelpText) {
|
|
128
|
+
t7 = enablePinning && /*#__PURE__*/ _jsxs(Stack, {
|
|
129
|
+
direction: "row",
|
|
130
|
+
alignItems: "center",
|
|
131
|
+
children: [
|
|
39
132
|
/*#__PURE__*/ _jsx(Typography, {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
133
|
+
sx: {
|
|
134
|
+
marginRight: 0.5,
|
|
135
|
+
fontSize: 11,
|
|
136
|
+
verticalAlign: "middle"
|
|
137
|
+
},
|
|
138
|
+
children: pinTooltipHelpText
|
|
139
|
+
}),
|
|
140
|
+
isTooltipPinned ? /*#__PURE__*/ _jsx(Pin, {
|
|
141
|
+
onClick: ()=>{
|
|
142
|
+
if (onUnpinClick !== undefined) {
|
|
143
|
+
onUnpinClick();
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
sx: {
|
|
147
|
+
fontSize: 16,
|
|
148
|
+
cursor: "pointer"
|
|
149
|
+
}
|
|
150
|
+
}) : /*#__PURE__*/ _jsx(PinOutline, {
|
|
151
|
+
sx: {
|
|
152
|
+
fontSize: 16
|
|
153
|
+
}
|
|
44
154
|
})
|
|
45
155
|
]
|
|
46
156
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}),
|
|
112
|
-
enablePinning && /*#__PURE__*/ _jsxs(Stack, {
|
|
113
|
-
direction: "row",
|
|
114
|
-
alignItems: "center",
|
|
115
|
-
children: [
|
|
116
|
-
/*#__PURE__*/ _jsx(Typography, {
|
|
117
|
-
sx: {
|
|
118
|
-
marginRight: 0.5,
|
|
119
|
-
fontSize: 11,
|
|
120
|
-
verticalAlign: 'middle'
|
|
121
|
-
},
|
|
122
|
-
children: pinTooltipHelpText
|
|
123
|
-
}),
|
|
124
|
-
isTooltipPinned ? /*#__PURE__*/ _jsx(Pin, {
|
|
125
|
-
onClick: ()=>{
|
|
126
|
-
if (onUnpinClick !== undefined) {
|
|
127
|
-
onUnpinClick();
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
sx: {
|
|
131
|
-
fontSize: 16,
|
|
132
|
-
cursor: 'pointer'
|
|
133
|
-
}
|
|
134
|
-
}) : /*#__PURE__*/ _jsx(PinOutline, {
|
|
135
|
-
sx: {
|
|
136
|
-
fontSize: 16
|
|
137
|
-
}
|
|
138
|
-
})
|
|
139
|
-
]
|
|
140
|
-
})
|
|
141
|
-
]
|
|
142
|
-
})
|
|
143
|
-
]
|
|
144
|
-
}),
|
|
145
|
-
/*#__PURE__*/ _jsx(Divider, {
|
|
146
|
-
sx: (theme)=>({
|
|
147
|
-
width: '100%',
|
|
148
|
-
borderColor: theme.palette.grey['500']
|
|
149
|
-
})
|
|
150
|
-
})
|
|
151
|
-
]
|
|
152
|
-
});
|
|
157
|
+
$[11] = enablePinning;
|
|
158
|
+
$[12] = isTooltipPinned;
|
|
159
|
+
$[13] = onUnpinClick;
|
|
160
|
+
$[14] = pinTooltipHelpText;
|
|
161
|
+
$[15] = t7;
|
|
162
|
+
} else {
|
|
163
|
+
t7 = $[15];
|
|
164
|
+
}
|
|
165
|
+
let t8;
|
|
166
|
+
if ($[16] !== t6 || $[17] !== t7) {
|
|
167
|
+
t8 = /*#__PURE__*/ _jsxs(Stack, {
|
|
168
|
+
direction: "row",
|
|
169
|
+
gap: 1,
|
|
170
|
+
sx: t5,
|
|
171
|
+
children: [
|
|
172
|
+
t6,
|
|
173
|
+
t7
|
|
174
|
+
]
|
|
175
|
+
});
|
|
176
|
+
$[16] = t6;
|
|
177
|
+
$[17] = t7;
|
|
178
|
+
$[18] = t8;
|
|
179
|
+
} else {
|
|
180
|
+
t8 = $[18];
|
|
181
|
+
}
|
|
182
|
+
let t9;
|
|
183
|
+
if ($[19] !== t4 || $[20] !== t8) {
|
|
184
|
+
t9 = /*#__PURE__*/ _jsxs(Box, {
|
|
185
|
+
sx: t3,
|
|
186
|
+
children: [
|
|
187
|
+
t4,
|
|
188
|
+
t8
|
|
189
|
+
]
|
|
190
|
+
});
|
|
191
|
+
$[19] = t4;
|
|
192
|
+
$[20] = t8;
|
|
193
|
+
$[21] = t9;
|
|
194
|
+
} else {
|
|
195
|
+
t9 = $[21];
|
|
196
|
+
}
|
|
197
|
+
let t10;
|
|
198
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
199
|
+
t10 = /*#__PURE__*/ _jsx(Divider, {
|
|
200
|
+
sx: _temp4
|
|
201
|
+
});
|
|
202
|
+
$[22] = t10;
|
|
203
|
+
} else {
|
|
204
|
+
t10 = $[22];
|
|
205
|
+
}
|
|
206
|
+
let t11;
|
|
207
|
+
if ($[23] !== t9) {
|
|
208
|
+
t11 = /*#__PURE__*/ _jsxs(Box, {
|
|
209
|
+
sx: _temp2,
|
|
210
|
+
children: [
|
|
211
|
+
t9,
|
|
212
|
+
t10
|
|
213
|
+
]
|
|
214
|
+
});
|
|
215
|
+
$[23] = t9;
|
|
216
|
+
$[24] = t11;
|
|
217
|
+
} else {
|
|
218
|
+
t11 = $[24];
|
|
219
|
+
}
|
|
220
|
+
return t11;
|
|
153
221
|
});
|
|
222
|
+
function _temp(theme) {
|
|
223
|
+
return {
|
|
224
|
+
color: theme.palette.common.white
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function _temp2(theme_0) {
|
|
228
|
+
return {
|
|
229
|
+
width: "100%",
|
|
230
|
+
maxWidth: TOOLTIP_MAX_WIDTH,
|
|
231
|
+
padding: theme_0.spacing(1.5, 2, 0.5, 2),
|
|
232
|
+
backgroundColor: theme_0.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,
|
|
233
|
+
position: "sticky",
|
|
234
|
+
top: 0,
|
|
235
|
+
left: 0
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function _temp3(theme_1) {
|
|
239
|
+
return {
|
|
240
|
+
"& .MuiSwitch-switchBase": {
|
|
241
|
+
color: theme_1.palette.common.white
|
|
242
|
+
},
|
|
243
|
+
"& .MuiSwitch-track": {
|
|
244
|
+
backgroundColor: theme_1.palette.common.white
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function _temp4(theme_2) {
|
|
249
|
+
return {
|
|
250
|
+
width: "100%",
|
|
251
|
+
borderColor: theme_2.palette.grey["500"]
|
|
252
|
+
};
|
|
253
|
+
}
|
|
154
254
|
|
|
155
255
|
//# sourceMappingURL=TooltipHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipHeader.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, Divider, Typography, Stack, Switch } from '@mui/material';\nimport Pin from 'mdi-material-ui/Pin';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport type { ReactElement } from 'react';\nimport { memo } from 'react';\n\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport {\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_MAX_WIDTH,\n PIN_TOOLTIP_HELP_TEXT,\n UNPIN_TOOLTIP_HELP_TEXT,\n} from './tooltip-model';\nimport type { NearbySeriesArray } from './types';\n\nexport interface TooltipHeaderProps {\n nearbySeries: NearbySeriesArray;\n totalSeries: number;\n isTooltipPinned: boolean;\n showAllSeries: boolean;\n enablePinning?: boolean;\n onShowAllClick?: (checked: boolean) => void;\n onUnpinClick?: () => void;\n}\n\nexport const TooltipHeader = memo(function TooltipHeader({\n nearbySeries,\n totalSeries,\n isTooltipPinned,\n showAllSeries,\n enablePinning = true,\n onShowAllClick,\n onUnpinClick,\n}: TooltipHeaderProps) {\n const { formatWithUserTimeZone } = useTimeZone();\n const seriesTimeMs = nearbySeries[0]?.date ?? null;\n if (seriesTimeMs === null) {\n return null;\n }\n\n const formatTimeSeriesHeader = (timeMs: number): ReactElement => {\n const date = new Date(timeMs);\n const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');\n const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');\n return (\n <Box>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedDate}\n </Typography>\n <Typography variant=\"caption\">\n <strong>{formattedTime}</strong>\n </Typography>\n </Box>\n );\n };\n\n // TODO: accurately calc whether more series are outside scrollable region using yBuffer, avg series name length, TOOLTIP_MAX_HEIGHT\n const showAllSeriesToggle = enablePinning && totalSeries > 5;\n\n const pinTooltipHelpText = isTooltipPinned ? UNPIN_TOOLTIP_HELP_TEXT : PIN_TOOLTIP_HELP_TEXT;\n\n return (\n <Box\n sx={(theme) => ({\n width: '100%',\n maxWidth: TOOLTIP_MAX_WIDTH,\n padding: theme.spacing(1.5, 2, 0.5, 2),\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n position: 'sticky',\n top: 0,\n left: 0,\n })}\n >\n <Box\n sx={{\n width: '100%',\n display: 'flex',\n justifyContent: 'start',\n alignItems: 'center',\n paddingBottom: 0.5,\n }}\n >\n {formatTimeSeriesHeader(seriesTimeMs)}\n <Stack direction=\"row\" gap={1} sx={{ marginLeft: 'auto' }}>\n {showAllSeriesToggle && (\n <Stack direction=\"row\" gap={0.5} alignItems=\"center\" sx={{ textAlign: 'right' }}>\n <Typography sx={{ fontSize: 11 }}>Show All</Typography>\n <Switch\n checked={showAllSeries}\n size=\"small\"\n onChange={(_, checked) => {\n if (onShowAllClick !== undefined) {\n return onShowAllClick(checked);\n }\n }}\n sx={(theme) => ({\n '& .MuiSwitch-switchBase': {\n color: theme.palette.common.white,\n },\n '& .MuiSwitch-track': {\n backgroundColor: theme.palette.common.white,\n },\n })}\n />\n </Stack>\n )}\n {enablePinning && (\n <Stack direction=\"row\" alignItems=\"center\">\n <Typography\n sx={{\n marginRight: 0.5,\n fontSize: 11,\n verticalAlign: 'middle',\n }}\n >\n {pinTooltipHelpText}\n </Typography>\n {isTooltipPinned ? (\n <Pin\n onClick={() => {\n if (onUnpinClick !== undefined) {\n onUnpinClick();\n }\n }}\n sx={{\n fontSize: 16,\n cursor: 'pointer',\n }}\n />\n ) : (\n <PinOutline sx={{ fontSize: 16 }} />\n )}\n </Stack>\n )}\n </Stack>\n </Box>\n <Divider\n sx={(theme) => ({\n width: '100%',\n borderColor: theme.palette.grey['500'],\n })}\n />\n </Box>\n );\n});\n"],"names":["Box","Divider","Typography","Stack","Switch","Pin","PinOutline","memo","useTimeZone","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_WIDTH","PIN_TOOLTIP_HELP_TEXT","UNPIN_TOOLTIP_HELP_TEXT","TooltipHeader"
|
|
1
|
+
{"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipHeader.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, Divider, Typography, Stack, Switch } from '@mui/material';\nimport Pin from 'mdi-material-ui/Pin';\nimport PinOutline from 'mdi-material-ui/PinOutline';\nimport type { ReactElement } from 'react';\nimport { memo } from 'react';\n\nimport { useTimeZone } from '../context/TimeZoneProvider';\nimport {\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_MAX_WIDTH,\n PIN_TOOLTIP_HELP_TEXT,\n UNPIN_TOOLTIP_HELP_TEXT,\n} from './tooltip-model';\nimport type { NearbySeriesArray } from './types';\n\nexport interface TooltipHeaderProps {\n nearbySeries: NearbySeriesArray;\n totalSeries: number;\n isTooltipPinned: boolean;\n showAllSeries: boolean;\n enablePinning?: boolean;\n onShowAllClick?: (checked: boolean) => void;\n onUnpinClick?: () => void;\n}\n\nexport const TooltipHeader = memo(function TooltipHeader({\n nearbySeries,\n totalSeries,\n isTooltipPinned,\n showAllSeries,\n enablePinning = true,\n onShowAllClick,\n onUnpinClick,\n}: TooltipHeaderProps) {\n const { formatWithUserTimeZone } = useTimeZone();\n const seriesTimeMs = nearbySeries[0]?.date ?? null;\n if (seriesTimeMs === null) {\n return null;\n }\n\n const formatTimeSeriesHeader = (timeMs: number): ReactElement => {\n const date = new Date(timeMs);\n const formattedDate = formatWithUserTimeZone(date, 'MMM dd, yyyy - ');\n const formattedTime = formatWithUserTimeZone(date, 'HH:mm:ss');\n return (\n <Box>\n <Typography\n variant=\"caption\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {formattedDate}\n </Typography>\n <Typography variant=\"caption\">\n <strong>{formattedTime}</strong>\n </Typography>\n </Box>\n );\n };\n\n // TODO: accurately calc whether more series are outside scrollable region using yBuffer, avg series name length, TOOLTIP_MAX_HEIGHT\n const showAllSeriesToggle = enablePinning && totalSeries > 5;\n\n const pinTooltipHelpText = isTooltipPinned ? UNPIN_TOOLTIP_HELP_TEXT : PIN_TOOLTIP_HELP_TEXT;\n\n return (\n <Box\n sx={(theme) => ({\n width: '100%',\n maxWidth: TOOLTIP_MAX_WIDTH,\n padding: theme.spacing(1.5, 2, 0.5, 2),\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n position: 'sticky',\n top: 0,\n left: 0,\n })}\n >\n <Box\n sx={{\n width: '100%',\n display: 'flex',\n justifyContent: 'start',\n alignItems: 'center',\n paddingBottom: 0.5,\n }}\n >\n {formatTimeSeriesHeader(seriesTimeMs)}\n <Stack direction=\"row\" gap={1} sx={{ marginLeft: 'auto' }}>\n {showAllSeriesToggle && (\n <Stack direction=\"row\" gap={0.5} alignItems=\"center\" sx={{ textAlign: 'right' }}>\n <Typography sx={{ fontSize: 11 }}>Show All</Typography>\n <Switch\n checked={showAllSeries}\n size=\"small\"\n onChange={(_, checked) => {\n if (onShowAllClick !== undefined) {\n return onShowAllClick(checked);\n }\n }}\n sx={(theme) => ({\n '& .MuiSwitch-switchBase': {\n color: theme.palette.common.white,\n },\n '& .MuiSwitch-track': {\n backgroundColor: theme.palette.common.white,\n },\n })}\n />\n </Stack>\n )}\n {enablePinning && (\n <Stack direction=\"row\" alignItems=\"center\">\n <Typography\n sx={{\n marginRight: 0.5,\n fontSize: 11,\n verticalAlign: 'middle',\n }}\n >\n {pinTooltipHelpText}\n </Typography>\n {isTooltipPinned ? (\n <Pin\n onClick={() => {\n if (onUnpinClick !== undefined) {\n onUnpinClick();\n }\n }}\n sx={{\n fontSize: 16,\n cursor: 'pointer',\n }}\n />\n ) : (\n <PinOutline sx={{ fontSize: 16 }} />\n )}\n </Stack>\n )}\n </Stack>\n </Box>\n <Divider\n sx={(theme) => ({\n width: '100%',\n borderColor: theme.palette.grey['500'],\n })}\n />\n </Box>\n );\n});\n"],"names":["Box","Divider","Typography","Stack","Switch","Pin","PinOutline","memo","useTimeZone","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_WIDTH","PIN_TOOLTIP_HELP_TEXT","UNPIN_TOOLTIP_HELP_TEXT","TooltipHeader"],"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,EAAEC,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,MAAM,QAAQ,gBAAgB;AACxE,OAAOC,SAAS,sBAAsB;AACtC,OAAOC,gBAAgB,6BAA6B;AAEpD,SAASC,IAAI,QAAQ,QAAQ;AAE7B,SAASC,WAAW,QAAQ,iCAA8B;AAC1D,SACEC,yBAAyB,EACzBC,iBAAiB,EACjBC,qBAAqB,EACrBC,uBAAuB,QAClB,qBAAkB;AAazB,OAAO,MAAMC,8BAAgBN,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4H/B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
1
2
|
// Copyright The Perses Authors
|
|
2
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
4
|
// you may not use this file except in compliance with the License.
|
|
@@ -18,16 +19,16 @@ export const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;
|
|
|
18
19
|
export const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;
|
|
19
20
|
export const TOOLTIP_PADDING = 8;
|
|
20
21
|
export const FALLBACK_CHART_WIDTH = 750;
|
|
21
|
-
export const NEARBY_SERIES_DESCRIPTION =
|
|
22
|
-
export const EMPHASIZED_SERIES_DESCRIPTION =
|
|
23
|
-
export const TOOLTIP_BG_COLOR_FALLBACK =
|
|
22
|
+
export const NEARBY_SERIES_DESCRIPTION = "nearby series showing in tooltip";
|
|
23
|
+
export const EMPHASIZED_SERIES_DESCRIPTION = "emphasized series showing as bold in tooltip";
|
|
24
|
+
export const TOOLTIP_BG_COLOR_FALLBACK = "#2E313E";
|
|
24
25
|
export const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {
|
|
25
|
-
year:
|
|
26
|
-
month:
|
|
27
|
-
day:
|
|
28
|
-
hour:
|
|
29
|
-
minute:
|
|
30
|
-
second:
|
|
26
|
+
year: "numeric",
|
|
27
|
+
month: "short",
|
|
28
|
+
day: "numeric",
|
|
29
|
+
hour: "numeric",
|
|
30
|
+
minute: "numeric",
|
|
31
|
+
second: "numeric",
|
|
31
32
|
hour12: true
|
|
32
33
|
});
|
|
33
34
|
export const defaultCursorData = {
|
|
@@ -46,42 +47,47 @@ export const defaultCursorData = {
|
|
|
46
47
|
};
|
|
47
48
|
export const EMPTY_TOOLTIP_DATA = [];
|
|
48
49
|
export const useMousePosition = ()=>{
|
|
50
|
+
const $ = _c(2);
|
|
49
51
|
const [coords, setCoords] = useState(null);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
let t0;
|
|
53
|
+
let t1;
|
|
54
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
55
|
+
t0 = ()=>{
|
|
56
|
+
const setFromEvent = (e)=>setCoords({
|
|
57
|
+
page: {
|
|
58
|
+
x: e.pageX,
|
|
59
|
+
y: e.pageY
|
|
60
|
+
},
|
|
61
|
+
client: {
|
|
62
|
+
x: e.clientX,
|
|
63
|
+
y: e.clientY
|
|
64
|
+
},
|
|
65
|
+
plotCanvas: {
|
|
66
|
+
x: e.zrX ?? e.offsetX,
|
|
67
|
+
y: e.zrY ?? e.offsetY
|
|
68
|
+
},
|
|
69
|
+
target: e.target
|
|
70
|
+
});
|
|
71
|
+
window.addEventListener("mousemove", setFromEvent);
|
|
72
|
+
return ()=>{
|
|
73
|
+
window.removeEventListener("mousemove", setFromEvent);
|
|
74
|
+
};
|
|
72
75
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
t1 = [];
|
|
77
|
+
$[0] = t0;
|
|
78
|
+
$[1] = t1;
|
|
79
|
+
} else {
|
|
80
|
+
t0 = $[0];
|
|
81
|
+
t1 = $[1];
|
|
82
|
+
}
|
|
83
|
+
useEffect(t0, t1);
|
|
78
84
|
return coords;
|
|
79
85
|
};
|
|
80
86
|
export const DEFAULT_TOOLTIP_CONFIG = {
|
|
81
87
|
wrapLabels: true,
|
|
82
88
|
enablePinning: true
|
|
83
89
|
};
|
|
84
|
-
export const PIN_TOOLTIP_HELP_TEXT =
|
|
85
|
-
export const UNPIN_TOOLTIP_HELP_TEXT =
|
|
90
|
+
export const PIN_TOOLTIP_HELP_TEXT = "Click chart to pin";
|
|
91
|
+
export const UNPIN_TOOLTIP_HELP_TEXT = "Click chart to unpin";
|
|
86
92
|
|
|
87
93
|
//# sourceMappingURL=tooltip-model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/TimeSeriesTooltip/tooltip-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 { useEffect, useState } from 'react';\n\nimport type { NearbySeriesArray } from './types';\n\nexport const TOOLTIP_MIN_WIDTH = 375;\nexport const TOOLTIP_MAX_WIDTH = 650;\nexport const TOOLTIP_MAX_HEIGHT = 650;\nexport const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;\nexport const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;\nexport const TOOLTIP_PADDING = 8;\n\nexport const FALLBACK_CHART_WIDTH = 750;\n\nexport const NEARBY_SERIES_DESCRIPTION = 'nearby series showing in tooltip';\nexport const EMPHASIZED_SERIES_DESCRIPTION = 'emphasized series showing as bold in tooltip';\n\nexport const TOOLTIP_BG_COLOR_FALLBACK = '#2E313E';\n\nexport const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n hour12: true,\n});\n\nexport const defaultCursorData = {\n coords: {\n plotCanvas: {\n x: 0,\n y: 0,\n },\n zrender: {\n x: 0,\n y: 0,\n },\n target: null,\n },\n chartWidth: 0,\n};\n\nexport const EMPTY_TOOLTIP_DATA: NearbySeriesArray = [];\n\n/**\n * ECharts is built with zrender, zrX and zrY are undefined when not hovering over a chart canvas\n */\nexport interface ZRCoordinate {\n x?: number;\n y?: number;\n}\n\nexport interface Coordinate {\n x: number;\n y: number;\n}\n\nexport interface CursorCoordinates {\n page: Coordinate;\n client: Coordinate;\n plotCanvas: ZRCoordinate;\n target: EventTarget | null;\n}\n\nexport interface CursorData {\n coords: CursorCoordinates | null;\n chartWidth?: number;\n}\n\nexport interface TooltipData {\n focusedSeries: NearbySeriesArray | null;\n cursor: CursorData;\n}\n\ntype ZREventProperties = {\n zrX?: number;\n zrY?: number;\n zrDelta?: number;\n zrEventControl?: 'no_globalout' | 'only_globalout';\n zrByTouch?: boolean;\n};\n\nexport type ZRRawMouseEvent = MouseEvent & ZREventProperties;\n\nexport const useMousePosition = (): CursorData['coords'] => {\n const [coords, setCoords] = useState<CursorData['coords']>(null);\n\n useEffect(() => {\n const setFromEvent = (e: ZRRawMouseEvent): void => {\n return setCoords({\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n // Default to zrender mousemove coords since they handle browser inconsistencies for us\n // ex: Firefox and Chrome have slightly different implementations of offsetX and offsetY\n // more info: https://github.com/ecomfe/zrender/blob/5.5.0/src/core/event.ts#L46-L120\n // Fallback to offsetX and offsetY to ensure tooltip works correctly in Edge\n x: e.zrX ?? e.offsetX,\n y: e.zrY ?? e.offsetY,\n },\n // necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)\n target: e.target,\n });\n };\n window.addEventListener('mousemove', setFromEvent);\n\n return (): void => {\n window.removeEventListener('mousemove', setFromEvent);\n };\n }, []);\n\n return coords;\n};\n\nexport type TooltipConfig = {\n wrapLabels: boolean;\n hidden?: boolean;\n enablePinning?: boolean;\n};\n\nexport const DEFAULT_TOOLTIP_CONFIG: TooltipConfig = {\n wrapLabels: true,\n enablePinning: true,\n};\n\nexport const PIN_TOOLTIP_HELP_TEXT = 'Click chart to pin';\n\nexport const UNPIN_TOOLTIP_HELP_TEXT = 'Click chart to unpin';\n"],"names":["useEffect","useState","TOOLTIP_MIN_WIDTH","TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_LABELS_MAX_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","TOOLTIP_PADDING","FALLBACK_CHART_WIDTH","NEARBY_SERIES_DESCRIPTION","EMPHASIZED_SERIES_DESCRIPTION","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_DATE_FORMAT","Intl","DateTimeFormat","undefined","year","month","day","hour","minute","second","hour12","defaultCursorData","coords","plotCanvas","x","y","zrender","target","chartWidth","EMPTY_TOOLTIP_DATA","useMousePosition","
|
|
1
|
+
{"version":3,"sources":["../../src/TimeSeriesTooltip/tooltip-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 { useEffect, useState } from 'react';\n\nimport type { NearbySeriesArray } from './types';\n\nexport const TOOLTIP_MIN_WIDTH = 375;\nexport const TOOLTIP_MAX_WIDTH = 650;\nexport const TOOLTIP_MAX_HEIGHT = 650;\nexport const TOOLTIP_LABELS_MAX_WIDTH = TOOLTIP_MAX_WIDTH - 150;\nexport const TOOLTIP_ADJUST_Y_POS_MULTIPLIER = 0.75;\nexport const TOOLTIP_PADDING = 8;\n\nexport const FALLBACK_CHART_WIDTH = 750;\n\nexport const NEARBY_SERIES_DESCRIPTION = 'nearby series showing in tooltip';\nexport const EMPHASIZED_SERIES_DESCRIPTION = 'emphasized series showing as bold in tooltip';\n\nexport const TOOLTIP_BG_COLOR_FALLBACK = '#2E313E';\n\nexport const TOOLTIP_DATE_FORMAT = new Intl.DateTimeFormat(undefined, {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n hour12: true,\n});\n\nexport const defaultCursorData = {\n coords: {\n plotCanvas: {\n x: 0,\n y: 0,\n },\n zrender: {\n x: 0,\n y: 0,\n },\n target: null,\n },\n chartWidth: 0,\n};\n\nexport const EMPTY_TOOLTIP_DATA: NearbySeriesArray = [];\n\n/**\n * ECharts is built with zrender, zrX and zrY are undefined when not hovering over a chart canvas\n */\nexport interface ZRCoordinate {\n x?: number;\n y?: number;\n}\n\nexport interface Coordinate {\n x: number;\n y: number;\n}\n\nexport interface CursorCoordinates {\n page: Coordinate;\n client: Coordinate;\n plotCanvas: ZRCoordinate;\n target: EventTarget | null;\n}\n\nexport interface CursorData {\n coords: CursorCoordinates | null;\n chartWidth?: number;\n}\n\nexport interface TooltipData {\n focusedSeries: NearbySeriesArray | null;\n cursor: CursorData;\n}\n\ntype ZREventProperties = {\n zrX?: number;\n zrY?: number;\n zrDelta?: number;\n zrEventControl?: 'no_globalout' | 'only_globalout';\n zrByTouch?: boolean;\n};\n\nexport type ZRRawMouseEvent = MouseEvent & ZREventProperties;\n\nexport const useMousePosition = (): CursorData['coords'] => {\n const [coords, setCoords] = useState<CursorData['coords']>(null);\n\n useEffect(() => {\n const setFromEvent = (e: ZRRawMouseEvent): void => {\n return setCoords({\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n // Default to zrender mousemove coords since they handle browser inconsistencies for us\n // ex: Firefox and Chrome have slightly different implementations of offsetX and offsetY\n // more info: https://github.com/ecomfe/zrender/blob/5.5.0/src/core/event.ts#L46-L120\n // Fallback to offsetX and offsetY to ensure tooltip works correctly in Edge\n x: e.zrX ?? e.offsetX,\n y: e.zrY ?? e.offsetY,\n },\n // necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)\n target: e.target,\n });\n };\n window.addEventListener('mousemove', setFromEvent);\n\n return (): void => {\n window.removeEventListener('mousemove', setFromEvent);\n };\n }, []);\n\n return coords;\n};\n\nexport type TooltipConfig = {\n wrapLabels: boolean;\n hidden?: boolean;\n enablePinning?: boolean;\n};\n\nexport const DEFAULT_TOOLTIP_CONFIG: TooltipConfig = {\n wrapLabels: true,\n enablePinning: true,\n};\n\nexport const PIN_TOOLTIP_HELP_TEXT = 'Click chart to pin';\n\nexport const UNPIN_TOOLTIP_HELP_TEXT = 'Click chart to unpin';\n"],"names":["useEffect","useState","TOOLTIP_MIN_WIDTH","TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_LABELS_MAX_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","TOOLTIP_PADDING","FALLBACK_CHART_WIDTH","NEARBY_SERIES_DESCRIPTION","EMPHASIZED_SERIES_DESCRIPTION","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_DATE_FORMAT","Intl","DateTimeFormat","undefined","year","month","day","hour","minute","second","hour12","defaultCursorData","coords","plotCanvas","x","y","zrender","target","chartWidth","EMPTY_TOOLTIP_DATA","useMousePosition","DEFAULT_TOOLTIP_CONFIG","wrapLabels","enablePinning","PIN_TOOLTIP_HELP_TEXT","UNPIN_TOOLTIP_HELP_TEXT"],"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,SAAS,EAAEC,QAAQ,QAAQ,QAAQ;AAI5C,OAAO,MAAMC,oBAAoB,IAAI;AACrC,OAAO,MAAMC,oBAAoB,IAAI;AACrC,OAAO,MAAMC,qBAAqB,IAAI;AACtC,OAAO,MAAMC,2BAA2BF,oBAAoB,IAAI;AAChE,OAAO,MAAMG,kCAAkC,KAAK;AACpD,OAAO,MAAMC,kBAAkB,EAAE;AAEjC,OAAO,MAAMC,uBAAuB,IAAI;AAExC,OAAO,MAAMC,4BAA4B,mCAAmC;AAC5E,OAAO,MAAMC,gCAAgC,+CAA+C;AAE5F,OAAO,MAAMC,4BAA4B,UAAU;AAEnD,OAAO,MAAMC,sBAAsB,IAAIC,KAAKC,cAAc,CAACC,WAAW;IACpEC,MAAM;IACNC,OAAO;IACPC,KAAK;IACLC,MAAM;IACNC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;AACV,GAAG;AAEH,OAAO,MAAMC,oBAAoB;IAC/BC,QAAQ;QACNC,YAAY;YACVC,GAAG;YACHC,GAAG;QACL;QACAC,SAAS;YACPF,GAAG;YACHC,GAAG;QACL;QACAE,QAAQ;IACV;IACAC,YAAY;AACd,EAAE;AAEF,OAAO,MAAMC,qBAAwC,EAAE,CAAC;AA0CxD,OAAO,MAAMC,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkC9B;AAQF,OAAO,MAAMC,yBAAwC;IACnDC,YAAY;IACZC,eAAe;AACjB,EAAE;AAEF,OAAO,MAAMC,wBAAwB,qBAAqB;AAE1D,OAAO,MAAMC,0BAA0B,uBAAuB"}
|