@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
|
@@ -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.
|
|
@@ -13,32 +14,56 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
14
|
// limitations under the License.
|
|
14
15
|
import { Box, Stack } from "@mui/material";
|
|
15
16
|
export function DropIndicator() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
const $ = _c(2);
|
|
18
|
+
let t0;
|
|
19
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
20
|
+
t0 = /*#__PURE__*/ _jsx(Box, {
|
|
21
|
+
sx: {
|
|
22
|
+
content: '""',
|
|
23
|
+
width: 8,
|
|
24
|
+
height: 8,
|
|
25
|
+
boxSizing: "border-box",
|
|
26
|
+
position: "absolute",
|
|
27
|
+
backgroundColor: _temp,
|
|
28
|
+
border: _temp2,
|
|
29
|
+
borderRadius: "50%"
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
$[0] = t0;
|
|
33
|
+
} else {
|
|
34
|
+
t0 = $[0];
|
|
35
|
+
}
|
|
36
|
+
let t1;
|
|
37
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
38
|
+
t1 = /*#__PURE__*/ _jsxs(Stack, {
|
|
39
|
+
direction: "row",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
children: [
|
|
42
|
+
t0,
|
|
43
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
44
|
+
sx: {
|
|
45
|
+
content: '""',
|
|
46
|
+
height: 2,
|
|
47
|
+
background: _temp3,
|
|
48
|
+
width: "100%"
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
$[1] = t1;
|
|
54
|
+
} else {
|
|
55
|
+
t1 = $[1];
|
|
56
|
+
}
|
|
57
|
+
return t1;
|
|
58
|
+
}
|
|
59
|
+
function _temp3(theme_1) {
|
|
60
|
+
return theme_1.palette.info.main;
|
|
61
|
+
}
|
|
62
|
+
function _temp2(theme_0) {
|
|
63
|
+
return `2px solid ${theme_0.palette.info.main}`;
|
|
64
|
+
}
|
|
65
|
+
function _temp(theme) {
|
|
66
|
+
return theme.palette.background.default;
|
|
42
67
|
}
|
|
43
68
|
|
|
44
69
|
//# sourceMappingURL=DropIndicator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/DragAndDrop/DropIndicator.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, Stack } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nexport function DropIndicator(): ReactElement {\n return (\n <Stack direction=\"row\" alignItems=\"center\">\n <Box\n sx={{\n content: '\"\"',\n width: 8,\n height: 8,\n boxSizing: 'border-box',\n position: 'absolute',\n backgroundColor: (theme) => theme.palette.background.default,\n border: (theme) => `2px solid ${theme.palette.info.main}`,\n borderRadius: '50%',\n }}\n ></Box>\n <Box\n sx={{\n content: '\"\"',\n height: 2,\n background: (theme) => theme.palette.info.main,\n width: '100%',\n }}\n ></Box>\n </Stack>\n );\n}\n"],"names":["Box","Stack"
|
|
1
|
+
{"version":3,"sources":["../../src/DragAndDrop/DropIndicator.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, Stack } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nexport function DropIndicator(): ReactElement {\n return (\n <Stack direction=\"row\" alignItems=\"center\">\n <Box\n sx={{\n content: '\"\"',\n width: 8,\n height: 8,\n boxSizing: 'border-box',\n position: 'absolute',\n backgroundColor: (theme) => theme.palette.background.default,\n border: (theme) => `2px solid ${theme.palette.info.main}`,\n borderRadius: '50%',\n }}\n ></Box>\n <Box\n sx={{\n content: '\"\"',\n height: 2,\n background: (theme) => theme.palette.info.main,\n width: '100%',\n }}\n ></Box>\n </Stack>\n );\n}\n"],"names":["Box","Stack"],"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,KAAK,QAAQ,gBAAgB;AAG3C,OAAO"}
|
package/dist/Drawer/Drawer.js
CHANGED
|
@@ -11,26 +11,86 @@
|
|
|
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 { Drawer as MuiDrawer, useMediaQuery } from "@mui/material";
|
|
15
16
|
import { combineSx } from "../utils/index.js";
|
|
16
17
|
const DRAWER_DEFAULT_WIDTH = 1080;
|
|
17
|
-
export const Drawer = (
|
|
18
|
+
export const Drawer = (t0)=>{
|
|
19
|
+
const $ = _c(21);
|
|
20
|
+
let PaperProps;
|
|
21
|
+
let children;
|
|
22
|
+
let isOpen;
|
|
23
|
+
let onClose;
|
|
24
|
+
let rest;
|
|
25
|
+
let t1;
|
|
26
|
+
if ($[0] !== t0) {
|
|
27
|
+
({ anchor: t1, isOpen, onClose, PaperProps, children, ...rest } = t0);
|
|
28
|
+
$[0] = t0;
|
|
29
|
+
$[1] = PaperProps;
|
|
30
|
+
$[2] = children;
|
|
31
|
+
$[3] = isOpen;
|
|
32
|
+
$[4] = onClose;
|
|
33
|
+
$[5] = rest;
|
|
34
|
+
$[6] = t1;
|
|
35
|
+
} else {
|
|
36
|
+
PaperProps = $[1];
|
|
37
|
+
children = $[2];
|
|
38
|
+
isOpen = $[3];
|
|
39
|
+
onClose = $[4];
|
|
40
|
+
rest = $[5];
|
|
41
|
+
t1 = $[6];
|
|
42
|
+
}
|
|
43
|
+
const anchor = t1 === undefined ? "right" : t1;
|
|
18
44
|
const isSmaller = useMediaQuery(`(max-width:${DRAWER_DEFAULT_WIDTH}px)`);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
45
|
+
const t2 = isSmaller ? "100%" : `${DRAWER_DEFAULT_WIDTH}px`;
|
|
46
|
+
let t3;
|
|
47
|
+
if ($[7] !== PaperProps?.sx || $[8] !== t2) {
|
|
48
|
+
t3 = combineSx({
|
|
49
|
+
width: t2,
|
|
50
|
+
overflow: "hidden"
|
|
51
|
+
}, PaperProps?.sx);
|
|
52
|
+
$[7] = PaperProps?.sx;
|
|
53
|
+
$[8] = t2;
|
|
54
|
+
$[9] = t3;
|
|
55
|
+
} else {
|
|
56
|
+
t3 = $[9];
|
|
57
|
+
}
|
|
58
|
+
let t4;
|
|
59
|
+
if ($[10] !== PaperProps || $[11] !== t3) {
|
|
60
|
+
t4 = {
|
|
25
61
|
...PaperProps,
|
|
26
|
-
sx:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
62
|
+
sx: t3
|
|
63
|
+
};
|
|
64
|
+
$[10] = PaperProps;
|
|
65
|
+
$[11] = t3;
|
|
66
|
+
$[12] = t4;
|
|
67
|
+
} else {
|
|
68
|
+
t4 = $[12];
|
|
69
|
+
}
|
|
70
|
+
const t5 = !isOpen;
|
|
71
|
+
let t6;
|
|
72
|
+
if ($[13] !== anchor || $[14] !== children || $[15] !== isOpen || $[16] !== onClose || $[17] !== rest || $[18] !== t4 || $[19] !== t5) {
|
|
73
|
+
t6 = /*#__PURE__*/ _jsx(MuiDrawer, {
|
|
74
|
+
...rest,
|
|
75
|
+
open: isOpen,
|
|
76
|
+
onClose: onClose,
|
|
77
|
+
anchor: anchor,
|
|
78
|
+
PaperProps: t4,
|
|
79
|
+
"aria-hidden": t5,
|
|
80
|
+
children: children
|
|
81
|
+
});
|
|
82
|
+
$[13] = anchor;
|
|
83
|
+
$[14] = children;
|
|
84
|
+
$[15] = isOpen;
|
|
85
|
+
$[16] = onClose;
|
|
86
|
+
$[17] = rest;
|
|
87
|
+
$[18] = t4;
|
|
88
|
+
$[19] = t5;
|
|
89
|
+
$[20] = t6;
|
|
90
|
+
} else {
|
|
91
|
+
t6 = $[20];
|
|
92
|
+
}
|
|
93
|
+
return t6;
|
|
34
94
|
};
|
|
35
95
|
|
|
36
96
|
//# sourceMappingURL=Drawer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Drawer/Drawer.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 { DrawerProps as MuiDrawerProps } from '@mui/material';\nimport { Drawer as MuiDrawer, useMediaQuery } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nimport { combineSx } from '../utils';\n\nexport interface DrawerProps extends MuiDrawerProps {\n isOpen: boolean;\n onClose: () => void;\n anchor?: 'left' | 'right';\n}\n\nconst DRAWER_DEFAULT_WIDTH = 1080;\n\nexport const Drawer = ({\n anchor = 'right',\n isOpen,\n onClose,\n PaperProps,\n children,\n ...rest\n}: DrawerProps): ReactElement => {\n const isSmaller = useMediaQuery(`(max-width:${DRAWER_DEFAULT_WIDTH}px)`);\n\n return (\n <MuiDrawer\n {...rest}\n open={isOpen}\n onClose={onClose}\n anchor={anchor}\n PaperProps={{\n ...PaperProps,\n sx: combineSx(\n {\n width: isSmaller ? '100%' : `${DRAWER_DEFAULT_WIDTH}px`,\n overflow: 'hidden',\n },\n PaperProps?.sx,\n ),\n }}\n aria-hidden={!isOpen} // Ensure the drawer is not focusable when closed + disable console.error about focusable elements\n >\n {children}\n </MuiDrawer>\n );\n};\n"],"names":["Drawer","MuiDrawer","useMediaQuery","combineSx","DRAWER_DEFAULT_WIDTH"
|
|
1
|
+
{"version":3,"sources":["../../src/Drawer/Drawer.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 { DrawerProps as MuiDrawerProps } from '@mui/material';\nimport { Drawer as MuiDrawer, useMediaQuery } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nimport { combineSx } from '../utils';\n\nexport interface DrawerProps extends MuiDrawerProps {\n isOpen: boolean;\n onClose: () => void;\n anchor?: 'left' | 'right';\n}\n\nconst DRAWER_DEFAULT_WIDTH = 1080;\n\nexport const Drawer = ({\n anchor = 'right',\n isOpen,\n onClose,\n PaperProps,\n children,\n ...rest\n}: DrawerProps): ReactElement => {\n const isSmaller = useMediaQuery(`(max-width:${DRAWER_DEFAULT_WIDTH}px)`);\n\n return (\n <MuiDrawer\n {...rest}\n open={isOpen}\n onClose={onClose}\n anchor={anchor}\n PaperProps={{\n ...PaperProps,\n sx: combineSx(\n {\n width: isSmaller ? '100%' : `${DRAWER_DEFAULT_WIDTH}px`,\n overflow: 'hidden',\n },\n PaperProps?.sx,\n ),\n }}\n aria-hidden={!isOpen} // Ensure the drawer is not focusable when closed + disable console.error about focusable elements\n >\n {children}\n </MuiDrawer>\n );\n};\n"],"names":["Drawer","MuiDrawer","useMediaQuery","combineSx","DRAWER_DEFAULT_WIDTH"],"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,UAAUC,SAAS,EAAEC,aAAa,QAAQ,gBAAgB;AAGnE,SAASC,SAAS,QAAQ,oBAAW;AAQrC,MAAMC,uBAAuB;AAE7B,OAAO,MAAMJ,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+BpB"}
|
package/dist/EChart/EChart.js
CHANGED
|
@@ -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 { Box } from "@mui/material";
|
|
15
16
|
import { BarChart as EChartsBarChart, LineChart as EChartsLineChart, GaugeChart as EChartsGaugeChart, PieChart as EChartsPieChart, ScatterChart as EChartsScatterChart, CustomChart as EChartsCustomChart, HeatmapChart as EChartsHeatmapChart } from "echarts/charts";
|
|
16
17
|
import { DatasetComponent, DataZoomComponent, LegendComponent, GridComponent, TitleComponent, TooltipComponent, VisualMapComponent, ToolboxComponent, MarkPointComponent, MarkAreaComponent, MarkLineComponent } from "echarts/components";
|
|
@@ -43,112 +44,200 @@ registerEChartsComponents([
|
|
|
43
44
|
MarkPointComponent
|
|
44
45
|
]);
|
|
45
46
|
const mouseEvents = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
47
|
+
"click",
|
|
48
|
+
"dblclick",
|
|
49
|
+
"mousedown",
|
|
50
|
+
"mousemove",
|
|
51
|
+
"mouseup",
|
|
52
|
+
"mouseover",
|
|
53
|
+
"mouseout",
|
|
54
|
+
"globalout",
|
|
55
|
+
"contextmenu"
|
|
55
56
|
];
|
|
56
57
|
const batchEvents = [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
"datazoom",
|
|
59
|
+
"downplay",
|
|
60
|
+
"highlight"
|
|
60
61
|
];
|
|
61
|
-
export const EChart = /*#__PURE__*/ memo(function EChart(
|
|
62
|
+
export const EChart = /*#__PURE__*/ memo(function EChart(t0) {
|
|
63
|
+
const $ = _c(20);
|
|
64
|
+
const { option, theme, renderer, sx, style, onEvents, _instance: instanceRef, syncGroup, onChartInitialized } = t0;
|
|
62
65
|
const initialOption = useRef(option);
|
|
63
66
|
const prevOption = useRef(option);
|
|
64
67
|
const containerRef = useRef(null);
|
|
65
68
|
const chartElement = useRef(null);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
chartElement.current
|
|
81
|
-
|
|
69
|
+
let t1;
|
|
70
|
+
let t2;
|
|
71
|
+
if ($[0] !== instanceRef || $[1] !== onChartInitialized || $[2] !== renderer || $[3] !== theme) {
|
|
72
|
+
t1 = ()=>{
|
|
73
|
+
if (containerRef.current === null || chartElement.current !== null) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
chartElement.current = init(containerRef.current, theme, {
|
|
77
|
+
renderer: renderer ?? "canvas"
|
|
78
|
+
});
|
|
79
|
+
if (chartElement.current === undefined) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
chartElement.current.setOption(initialOption.current, true);
|
|
83
|
+
onChartInitialized?.(chartElement.current);
|
|
84
|
+
if (instanceRef !== undefined) {
|
|
85
|
+
instanceRef.current = chartElement.current;
|
|
86
|
+
}
|
|
87
|
+
return ()=>{
|
|
88
|
+
if (chartElement.current === null) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
chartElement.current.dispose();
|
|
92
|
+
chartElement.current = null;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
t2 = [
|
|
96
|
+
instanceRef,
|
|
97
|
+
onChartInitialized,
|
|
98
|
+
theme,
|
|
99
|
+
renderer
|
|
100
|
+
];
|
|
101
|
+
$[0] = instanceRef;
|
|
102
|
+
$[1] = onChartInitialized;
|
|
103
|
+
$[2] = renderer;
|
|
104
|
+
$[3] = theme;
|
|
105
|
+
$[4] = t1;
|
|
106
|
+
$[5] = t2;
|
|
107
|
+
} else {
|
|
108
|
+
t1 = $[4];
|
|
109
|
+
t2 = $[5];
|
|
110
|
+
}
|
|
111
|
+
useLayoutEffect(t1, t2);
|
|
112
|
+
let t3;
|
|
113
|
+
let t4;
|
|
114
|
+
if ($[6] !== syncGroup) {
|
|
115
|
+
t3 = ()=>{
|
|
116
|
+
if (!chartElement.current || !syncGroup) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
chartElement.current.group = syncGroup;
|
|
120
|
+
connect([
|
|
121
|
+
chartElement.current
|
|
122
|
+
]);
|
|
123
|
+
};
|
|
124
|
+
t4 = [
|
|
125
|
+
syncGroup,
|
|
126
|
+
chartElement
|
|
127
|
+
];
|
|
128
|
+
$[6] = syncGroup;
|
|
129
|
+
$[7] = t3;
|
|
130
|
+
$[8] = t4;
|
|
131
|
+
} else {
|
|
132
|
+
t3 = $[7];
|
|
133
|
+
t4 = $[8];
|
|
134
|
+
}
|
|
135
|
+
useEffect(t3, t4);
|
|
136
|
+
let t5;
|
|
137
|
+
let t6;
|
|
138
|
+
if ($[9] !== option) {
|
|
139
|
+
t5 = ()=>{
|
|
140
|
+
if (prevOption.current === undefined || isEqual(prevOption.current, option)) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (!chartElement.current) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
chartElement.current.setOption(option, true);
|
|
147
|
+
prevOption.current = option;
|
|
82
148
|
};
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
chartElement.current?.resize();
|
|
115
|
-
}, 200);
|
|
116
|
-
const observer = new ResizeObserver(updateSize);
|
|
117
|
-
observer.observe(container);
|
|
118
|
-
window.addEventListener('resize', updateSize);
|
|
119
|
-
updateSize();
|
|
120
|
-
return ()=>{
|
|
121
|
-
observer.disconnect();
|
|
122
|
-
window.removeEventListener('resize', updateSize);
|
|
123
|
-
updateSize.cancel();
|
|
149
|
+
t6 = [
|
|
150
|
+
option
|
|
151
|
+
];
|
|
152
|
+
$[9] = option;
|
|
153
|
+
$[10] = t5;
|
|
154
|
+
$[11] = t6;
|
|
155
|
+
} else {
|
|
156
|
+
t5 = $[10];
|
|
157
|
+
t6 = $[11];
|
|
158
|
+
}
|
|
159
|
+
useEffect(t5, t6);
|
|
160
|
+
let t7;
|
|
161
|
+
let t8;
|
|
162
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
163
|
+
t7 = ()=>{
|
|
164
|
+
const container = containerRef.current;
|
|
165
|
+
if (!container) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const updateSize = debounce(()=>{
|
|
169
|
+
chartElement.current?.resize();
|
|
170
|
+
}, 200);
|
|
171
|
+
const observer = new ResizeObserver(updateSize);
|
|
172
|
+
observer.observe(container);
|
|
173
|
+
window.addEventListener("resize", updateSize);
|
|
174
|
+
updateSize();
|
|
175
|
+
return ()=>{
|
|
176
|
+
observer.disconnect();
|
|
177
|
+
window.removeEventListener("resize", updateSize);
|
|
178
|
+
updateSize.cancel();
|
|
179
|
+
};
|
|
124
180
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
181
|
+
t8 = [];
|
|
182
|
+
$[12] = t7;
|
|
183
|
+
$[13] = t8;
|
|
184
|
+
} else {
|
|
185
|
+
t7 = $[12];
|
|
186
|
+
t8 = $[13];
|
|
187
|
+
}
|
|
188
|
+
useLayoutEffect(t7, t8);
|
|
189
|
+
let t10;
|
|
190
|
+
let t9;
|
|
191
|
+
if ($[14] !== onEvents) {
|
|
192
|
+
t9 = ()=>{
|
|
193
|
+
const chart = chartElement.current;
|
|
194
|
+
if (!chart || onEvents === undefined) {
|
|
195
|
+
return;
|
|
136
196
|
}
|
|
197
|
+
bindEvents(chart, onEvents);
|
|
198
|
+
return ()=>{
|
|
199
|
+
if (chart === undefined) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (chart.isDisposed() === true) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
for(const event in onEvents){
|
|
206
|
+
chart.off(event);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
137
209
|
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
210
|
+
t10 = [
|
|
211
|
+
onEvents
|
|
212
|
+
];
|
|
213
|
+
$[14] = onEvents;
|
|
214
|
+
$[15] = t10;
|
|
215
|
+
$[16] = t9;
|
|
216
|
+
} else {
|
|
217
|
+
t10 = $[15];
|
|
218
|
+
t9 = $[16];
|
|
219
|
+
}
|
|
220
|
+
useEffect(t9, t10);
|
|
221
|
+
let t11;
|
|
222
|
+
if ($[17] !== style || $[18] !== sx) {
|
|
223
|
+
t11 = /*#__PURE__*/ _jsx(Box, {
|
|
224
|
+
ref: containerRef,
|
|
225
|
+
sx: sx,
|
|
226
|
+
style: style
|
|
227
|
+
});
|
|
228
|
+
$[17] = style;
|
|
229
|
+
$[18] = sx;
|
|
230
|
+
$[19] = t11;
|
|
231
|
+
} else {
|
|
232
|
+
t11 = $[19];
|
|
233
|
+
}
|
|
234
|
+
return t11;
|
|
146
235
|
});
|
|
147
236
|
// Validate event config and bind custom events
|
|
148
237
|
function bindEvents(instance, events) {
|
|
149
238
|
if (events === undefined) return;
|
|
150
239
|
function bindEvent(eventName, OnEventFunction) {
|
|
151
|
-
if (typeof OnEventFunction ===
|
|
240
|
+
if (typeof OnEventFunction === "function") {
|
|
152
241
|
if (isMouseEvent(eventName)) {
|
|
153
242
|
instance.on(eventName, (params)=>OnEventFunction(params, instance));
|
|
154
243
|
} else if (isBatchEvent(eventName)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/EChart/EChart.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 { SxProps, Theme } from '@mui/material';\nimport { Box } from '@mui/material';\nimport {\n BarChart as EChartsBarChart,\n LineChart as EChartsLineChart,\n GaugeChart as EChartsGaugeChart,\n PieChart as EChartsPieChart,\n ScatterChart as EChartsScatterChart,\n CustomChart as EChartsCustomChart,\n HeatmapChart as EChartsHeatmapChart,\n} from 'echarts/charts';\nimport {\n DatasetComponent,\n DataZoomComponent,\n LegendComponent,\n GridComponent,\n TitleComponent,\n TooltipComponent,\n VisualMapComponent,\n ToolboxComponent,\n MarkPointComponent,\n MarkAreaComponent,\n MarkLineComponent,\n} from 'echarts/components';\nimport type { ECharts, EChartsCoreOption } from 'echarts/core';\nimport { init, connect, use as registerEChartsComponents } from 'echarts/core';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport debounce from 'lodash/debounce';\nimport isEqual from 'lodash/isEqual';\nimport type { CSSProperties } from 'react';\nimport { memo, useEffect, useLayoutEffect, useRef } from 'react';\n\nimport type { EChartsTheme } from '../model';\n\n// Loading the ECharts extensions should happen in the respective plugins.\n// This is a workaround for https://github.com/perses/plugins/issues/83.\nregisterEChartsComponents([\n DatasetComponent,\n DataZoomComponent,\n LegendComponent,\n EChartsBarChart,\n EChartsLineChart,\n EChartsGaugeChart,\n EChartsPieChart,\n EChartsScatterChart,\n EChartsCustomChart,\n EChartsHeatmapChart,\n GridComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n CanvasRenderer,\n VisualMapComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n]);\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts,\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = (typeof mouseEvents)[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = (typeof batchEvents)[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n style?: CSSProperties;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n syncGroup?: string;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n style,\n onEvents,\n _instance: instanceRef,\n syncGroup,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (instanceRef !== undefined) {\n instanceRef.current = chartElement.current;\n }\n return (): void => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [instanceRef, onChartInitialized, theme, renderer]);\n\n // When syncGroup is explicitly set, charts within same group share interactions such as crosshair\n useEffect(() => {\n if (!chartElement.current || !syncGroup) return;\n chartElement.current.group = syncGroup;\n connect([chartElement.current]); // more info: https://echarts.apache.org/en/api.html#echarts.connect\n }, [syncGroup, chartElement]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Observe actual container size, including layout and style changes.\n useLayoutEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n const updateSize = debounce(() => {\n chartElement.current?.resize();\n }, 200);\n const observer = new ResizeObserver(updateSize);\n observer.observe(container);\n window.addEventListener('resize', updateSize);\n updateSize();\n return (): void => {\n observer.disconnect();\n window.removeEventListener('resize', updateSize);\n updateSize.cancel();\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return (): void => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n return <Box ref={containerRef} sx={sx} style={style}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>): void {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown): void {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["Box","BarChart","EChartsBarChart","LineChart","EChartsLineChart","GaugeChart","EChartsGaugeChart","PieChart","EChartsPieChart","ScatterChart","EChartsScatterChart","CustomChart","EChartsCustomChart","HeatmapChart","EChartsHeatmapChart","DatasetComponent","DataZoomComponent","LegendComponent","GridComponent","TitleComponent","TooltipComponent","VisualMapComponent","ToolboxComponent","MarkPointComponent","MarkAreaComponent","MarkLineComponent","init","connect","use","registerEChartsComponents","CanvasRenderer","debounce","isEqual","memo","useEffect","useLayoutEffect","useRef","mouseEvents","batchEvents","EChart","option","theme","renderer","sx","style","onEvents","_instance","instanceRef","syncGroup","onChartInitialized","initialOption","prevOption","containerRef","chartElement","current","undefined","setOption","dispose","group","container","updateSize","resize","observer","ResizeObserver","observe","window","addEventListener","disconnect","removeEventListener","cancel","chart","bindEvents","isDisposed","event","off","ref","instance","events","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"mappings":"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"}
|
|
1
|
+
{"version":3,"sources":["../../src/EChart/EChart.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 { SxProps, Theme } from '@mui/material';\nimport { Box } from '@mui/material';\nimport {\n BarChart as EChartsBarChart,\n LineChart as EChartsLineChart,\n GaugeChart as EChartsGaugeChart,\n PieChart as EChartsPieChart,\n ScatterChart as EChartsScatterChart,\n CustomChart as EChartsCustomChart,\n HeatmapChart as EChartsHeatmapChart,\n} from 'echarts/charts';\nimport {\n DatasetComponent,\n DataZoomComponent,\n LegendComponent,\n GridComponent,\n TitleComponent,\n TooltipComponent,\n VisualMapComponent,\n ToolboxComponent,\n MarkPointComponent,\n MarkAreaComponent,\n MarkLineComponent,\n} from 'echarts/components';\nimport type { ECharts, EChartsCoreOption } from 'echarts/core';\nimport { init, connect, use as registerEChartsComponents } from 'echarts/core';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport debounce from 'lodash/debounce';\nimport isEqual from 'lodash/isEqual';\nimport type { CSSProperties } from 'react';\nimport { memo, useEffect, useLayoutEffect, useRef } from 'react';\n\nimport type { EChartsTheme } from '../model';\n\n// Loading the ECharts extensions should happen in the respective plugins.\n// This is a workaround for https://github.com/perses/plugins/issues/83.\nregisterEChartsComponents([\n DatasetComponent,\n DataZoomComponent,\n LegendComponent,\n EChartsBarChart,\n EChartsLineChart,\n EChartsGaugeChart,\n EChartsPieChart,\n EChartsScatterChart,\n EChartsCustomChart,\n EChartsHeatmapChart,\n GridComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n CanvasRenderer,\n VisualMapComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n]);\n\n// see docs for info about each property: https://echarts.apache.org/en/api.html#events\nexport interface MouseEventsParameters<T> {\n componentType: string;\n seriesType: string;\n seriesIndex: number;\n seriesName: string;\n name: string;\n dataIndex: number;\n data: Record<string, unknown> & T;\n dataType: string;\n value: number | number[];\n color: string;\n info: Record<string, unknown>;\n}\n\ntype OnEventFunction<T> = (\n params: MouseEventsParameters<T>,\n // This is potentially undefined for testing purposes\n instance?: ECharts,\n) => void;\n\nconst mouseEvents = [\n 'click',\n 'dblclick',\n 'mousedown',\n 'mousemove',\n 'mouseup',\n 'mouseover',\n 'mouseout',\n 'globalout',\n 'contextmenu',\n] as const;\n\nexport type MouseEventName = (typeof mouseEvents)[number];\n\n// batch event types\nexport interface DataZoomPayloadBatchItem {\n dataZoomId: string;\n // start and end not returned unless dataZoom is based on percentProp,\n // which is for cases when a dataZoom component controls multiple axes\n start?: number;\n end?: number;\n // startValue and endValue return data index for 'category' axes,\n // for axis types 'value' and 'time', actual values are returned\n startValue?: number;\n endValue?: number;\n}\n\nexport interface HighlightPayloadBatchItem {\n dataIndex: number;\n dataIndexInside: number;\n seriesIndex: number;\n // highlight action can effect multiple connected charts\n escapeConnect?: boolean;\n // whether blur state was triggered\n notBlur?: boolean;\n}\n\nexport interface BatchEventsParameters {\n type: BatchEventName;\n batch: DataZoomPayloadBatchItem[] & HighlightPayloadBatchItem[];\n}\n\ntype OnBatchEventFunction = (params: BatchEventsParameters) => void;\n\nconst batchEvents = ['datazoom', 'downplay', 'highlight'] as const;\n\nexport type BatchEventName = (typeof batchEvents)[number];\n\ntype ChartEventName = 'finished';\n\ntype EventName = MouseEventName | ChartEventName | BatchEventName;\n\nexport type OnEventsType<T> = {\n [mouseEventName in MouseEventName]?: OnEventFunction<T>;\n} & {\n [batchEventName in BatchEventName]?: OnBatchEventFunction;\n} & {\n [eventName in ChartEventName]?: () => void;\n};\n\nexport interface EChartsProps<T> {\n option: EChartsCoreOption;\n theme?: string | EChartsTheme;\n renderer?: 'canvas' | 'svg';\n sx?: SxProps<Theme>;\n style?: CSSProperties;\n onEvents?: OnEventsType<T>;\n _instance?: React.MutableRefObject<ECharts | undefined>;\n syncGroup?: string;\n onChartInitialized?: (instance: ECharts) => void;\n}\n\nexport const EChart = memo(function EChart<T>({\n option,\n theme,\n renderer,\n sx,\n style,\n onEvents,\n _instance: instanceRef,\n syncGroup,\n onChartInitialized,\n}: EChartsProps<T>) {\n const initialOption = useRef<EChartsCoreOption>(option);\n const prevOption = useRef<EChartsCoreOption>(option);\n const containerRef = useRef<HTMLDivElement | null>(null);\n const chartElement = useRef<ECharts | null>(null);\n\n // Initialize chart, dispose on unmount\n useLayoutEffect(() => {\n if (containerRef.current === null || chartElement.current !== null) return;\n chartElement.current = init(containerRef.current, theme, { renderer: renderer ?? 'canvas' });\n if (chartElement.current === undefined) return;\n chartElement.current.setOption(initialOption.current, true);\n onChartInitialized?.(chartElement.current);\n if (instanceRef !== undefined) {\n instanceRef.current = chartElement.current;\n }\n return (): void => {\n if (chartElement.current === null) return;\n chartElement.current.dispose();\n chartElement.current = null;\n };\n }, [instanceRef, onChartInitialized, theme, renderer]);\n\n // When syncGroup is explicitly set, charts within same group share interactions such as crosshair\n useEffect(() => {\n if (!chartElement.current || !syncGroup) return;\n chartElement.current.group = syncGroup;\n connect([chartElement.current]); // more info: https://echarts.apache.org/en/api.html#echarts.connect\n }, [syncGroup, chartElement]);\n\n // Update chart data when option changes\n useEffect(() => {\n if (prevOption.current === undefined || isEqual(prevOption.current, option)) return;\n if (!chartElement.current) return;\n chartElement.current.setOption(option, true);\n prevOption.current = option;\n }, [option]);\n\n // Observe actual container size, including layout and style changes.\n useLayoutEffect(() => {\n const container = containerRef.current;\n if (!container) return;\n const updateSize = debounce(() => {\n chartElement.current?.resize();\n }, 200);\n const observer = new ResizeObserver(updateSize);\n observer.observe(container);\n window.addEventListener('resize', updateSize);\n updateSize();\n return (): void => {\n observer.disconnect();\n window.removeEventListener('resize', updateSize);\n updateSize.cancel();\n };\n }, []);\n\n // Bind and unbind chart events passed as prop\n useEffect(() => {\n const chart = chartElement.current;\n if (!chart || onEvents === undefined) return;\n bindEvents(chart, onEvents);\n return (): void => {\n if (chart === undefined) return;\n if (chart.isDisposed() === true) return;\n for (const event in onEvents) {\n chart.off(event);\n }\n };\n }, [onEvents]);\n\n return <Box ref={containerRef} sx={sx} style={style}></Box>;\n});\n\n// Validate event config and bind custom events\nfunction bindEvents<T>(instance: ECharts, events?: OnEventsType<T>): void {\n if (events === undefined) return;\n\n function bindEvent(eventName: EventName, OnEventFunction: unknown): void {\n if (typeof OnEventFunction === 'function') {\n if (isMouseEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params, instance));\n } else if (isBatchEvent(eventName)) {\n instance.on(eventName, (params) => OnEventFunction(params));\n } else {\n instance.on(eventName, () => OnEventFunction(null, instance));\n }\n }\n }\n\n for (const eventName in events) {\n if (Object.prototype.hasOwnProperty.call(events, eventName)) {\n const customEvent = events[eventName as EventName] ?? null;\n if (customEvent) {\n bindEvent(eventName as EventName, customEvent);\n }\n }\n }\n}\n\nfunction isMouseEvent(eventName: EventName): eventName is MouseEventName {\n return (mouseEvents as readonly string[]).includes(eventName);\n}\n\nfunction isBatchEvent(eventName: EventName): eventName is BatchEventName {\n return (batchEvents as readonly string[]).includes(eventName);\n}\n"],"names":["Box","BarChart","EChartsBarChart","LineChart","EChartsLineChart","GaugeChart","EChartsGaugeChart","PieChart","EChartsPieChart","ScatterChart","EChartsScatterChart","CustomChart","EChartsCustomChart","HeatmapChart","EChartsHeatmapChart","DatasetComponent","DataZoomComponent","LegendComponent","GridComponent","TitleComponent","TooltipComponent","VisualMapComponent","ToolboxComponent","MarkPointComponent","MarkAreaComponent","MarkLineComponent","init","connect","use","registerEChartsComponents","CanvasRenderer","debounce","isEqual","memo","useEffect","useLayoutEffect","useRef","mouseEvents","batchEvents","EChart","bindEvents","instance","events","undefined","bindEvent","eventName","OnEventFunction","isMouseEvent","on","params","isBatchEvent","Object","prototype","hasOwnProperty","call","customEvent","includes"],"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;AACpC,SACEC,YAAYC,eAAe,EAC3BC,aAAaC,gBAAgB,EAC7BC,cAAcC,iBAAiB,EAC/BC,YAAYC,eAAe,EAC3BC,gBAAgBC,mBAAmB,EACnCC,eAAeC,kBAAkB,EACjCC,gBAAgBC,mBAAmB,QAC9B,iBAAiB;AACxB,SACEC,gBAAgB,EAChBC,iBAAiB,EACjBC,eAAe,EACfC,aAAa,EACbC,cAAc,EACdC,gBAAgB,EAChBC,kBAAkB,EAClBC,gBAAgB,EAChBC,kBAAkB,EAClBC,iBAAiB,EACjBC,iBAAiB,QACZ,qBAAqB;AAE5B,SAASC,IAAI,EAAEC,OAAO,EAAEC,OAAOC,yBAAyB,QAAQ,eAAe;AAC/E,SAASC,cAAc,QAAQ,oBAAoB;AACnD,OAAOC,cAAc,kBAAkB;AACvC,OAAOC,aAAa,iBAAiB;AAErC,SAASC,IAAI,EAAEC,SAAS,EAAEC,eAAe,EAAEC,MAAM,QAAQ,QAAQ;AAIjE,0EAA0E;AAC1E,wEAAwE;AACxEP,0BAA0B;IACxBd;IACAC;IACAC;IACAf;IACAE;IACAE;IACAE;IACAE;IACAE;IACAE;IACAI;IACAC;IACAG;IACAF;IACAU;IACAT;IACAG;IACAC;IACAF;CACD;AAuBD,MAAMc,cAAc;IAClB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAkCD,MAAMC,cAAc;IAAC;IAAY;IAAY;CAAY;AA4BzD,OAAO,MAAMC,uBAASN,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFxB;AAEH,+CAA+C;AAC/C,SAASO,WAAcC,QAAQ,EAAWC,MAAM;IAC9C,IAAIA,WAAWC,WAAW;IAE1B,SAASC,UAAUC,SAAS,EAAaC,eAAe;QACtD,IAAI,OAAOA,oBAAoB,YAAY;YACzC,IAAIC,aAAaF,YAAY;gBAC3BJ,SAASO,EAAE,CAACH,WAAW,CAACI,SAAWH,gBAAgBG,QAAQR;YAC7D,OAAO,IAAIS,aAAaL,YAAY;gBAClCJ,SAASO,EAAE,CAACH,WAAW,CAACI,SAAWH,gBAAgBG;YACrD,OAAO;gBACLR,SAASO,EAAE,CAACH,WAAW,IAAMC,gBAAgB,MAAML;YACrD;QACF;IACF;IAEA,IAAK,MAAMI,aAAaH,OAAQ;QAC9B,IAAIS,OAAOC,SAAS,CAACC,cAAc,CAACC,IAAI,CAACZ,QAAQG,YAAY;YAC3D,MAAMU,cAAcb,MAAOG,CAAAA,UAAsB,AAAC,IAAI;YACtD,IAAIU,aAAa;gBACfX,UAAUC,WAAwBU;YACpC;QACF;IACF;AACF;AAEA,SAASR,aAAaF,SAAS;IAC7B,OAAO,AAACR,YAAkCmB,QAAQ,CAACX;AACrD;AAEA,SAASK,aAAaL,SAAS;IAC7B,OAAO,AAACP,YAAkCkB,QAAQ,CAACX;AACrD"}
|
package/dist/ErrorAlert.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.
|
|
@@ -15,11 +16,20 @@ import { Alert } from "@mui/material";
|
|
|
15
16
|
/**
|
|
16
17
|
* Shows an MUI Alert with the `Error.message` as its contents.
|
|
17
18
|
*/ export function ErrorAlert(props) {
|
|
19
|
+
const $ = _c(2);
|
|
18
20
|
const { error } = props;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
let t0;
|
|
22
|
+
if ($[0] !== error.message) {
|
|
23
|
+
t0 = /*#__PURE__*/ _jsx(Alert, {
|
|
24
|
+
severity: "error",
|
|
25
|
+
children: error.message
|
|
26
|
+
});
|
|
27
|
+
$[0] = error.message;
|
|
28
|
+
$[1] = t0;
|
|
29
|
+
} else {
|
|
30
|
+
t0 = $[1];
|
|
31
|
+
}
|
|
32
|
+
return t0;
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
//# sourceMappingURL=ErrorAlert.js.map
|
package/dist/ErrorAlert.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ErrorAlert.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 { Alert } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nexport interface ErrorAlertProps {\n error: Error;\n}\n\n/**\n * Shows an MUI Alert with the `Error.message` as its contents.\n */\nexport function ErrorAlert(props: ErrorAlertProps): ReactElement {\n const { error } = props;\n return <Alert severity=\"error\">{error.message}</Alert>;\n}\n"],"names":["Alert"
|
|
1
|
+
{"version":3,"sources":["../src/ErrorAlert.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 { Alert } from '@mui/material';\nimport type { ReactElement } from 'react';\n\nexport interface ErrorAlertProps {\n error: Error;\n}\n\n/**\n * Shows an MUI Alert with the `Error.message` as its contents.\n */\nexport function ErrorAlert(props: ErrorAlertProps): ReactElement {\n const { error } = props;\n return <Alert severity=\"error\">{error.message}</Alert>;\n}\n"],"names":["Alert"],"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,KAAK,QAAQ,gBAAgB;AAOtC;;CAEC,GACD,OAAO"}
|