@perses-dev/components 0.8.1 → 0.9.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/Drawer/Drawer.d.ts +3 -4
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +35 -1
- package/dist/Drawer/Drawer.js.map +1 -0
- package/dist/Drawer/index.js +15 -1
- package/dist/Drawer/index.js.map +1 -0
- package/dist/EChart.d.ts.map +1 -1
- package/dist/EChart.js +142 -1
- package/dist/EChart.js.map +1 -0
- package/dist/ErrorAlert.js +25 -1
- package/dist/ErrorAlert.js.map +1 -0
- package/dist/ErrorBoundary.js +16 -1
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/GaugeChart/GaugeChart.js +172 -1
- package/dist/GaugeChart/GaugeChart.js.map +1 -0
- package/dist/GaugeChart/index.js +15 -1
- package/dist/GaugeChart/index.js.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.js +79 -1
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.test.js +36 -1
- package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
- package/dist/InfoTooltip/index.js +15 -1
- package/dist/InfoTooltip/index.js.map +1 -0
- package/dist/LineChart/LineChart.js +198 -1
- package/dist/LineChart/LineChart.js.map +1 -0
- package/dist/LineChart/index.js +15 -1
- package/dist/LineChart/index.js.map +1 -0
- package/dist/LineChart/utils.js +63 -1
- package/dist/LineChart/utils.js.map +1 -0
- package/dist/StatChart/StatChart.js +121 -1
- package/dist/StatChart/StatChart.js.map +1 -0
- package/dist/StatChart/StatChart.test.js +82 -1
- package/dist/StatChart/StatChart.test.js.map +1 -0
- package/dist/StatChart/index.js +15 -1
- package/dist/StatChart/index.js.map +1 -0
- package/dist/TimeRangeSelector/AbsoluteTimePicker.js +175 -1
- package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +1 -0
- package/dist/TimeRangeSelector/TimeRangeSelector.js +52 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
- package/dist/TimeRangeSelector/index.js +16 -1
- package/dist/TimeRangeSelector/index.js.map +1 -0
- package/dist/TimeRangeSelector/utils.js +36 -1
- package/dist/TimeRangeSelector/utils.js.map +1 -0
- package/dist/Tooltip/SeriesInfo.js +143 -1
- package/dist/Tooltip/SeriesInfo.js.map +1 -0
- package/dist/Tooltip/SeriesMarker.js +33 -1
- package/dist/Tooltip/SeriesMarker.js.map +1 -0
- package/dist/Tooltip/Tooltip.js +72 -1
- package/dist/Tooltip/Tooltip.js.map +1 -0
- package/dist/Tooltip/TooltipContent.js +89 -1
- package/dist/Tooltip/TooltipContent.js.map +1 -0
- package/dist/Tooltip/focused-series.js +108 -1
- package/dist/Tooltip/focused-series.js.map +1 -0
- package/dist/Tooltip/focused-series.test.js +75 -1
- package/dist/Tooltip/focused-series.test.js.map +1 -0
- package/dist/Tooltip/index.js +16 -1
- package/dist/Tooltip/index.js.map +1 -0
- package/dist/Tooltip/tooltip-model.js +80 -1
- package/dist/Tooltip/tooltip-model.js.map +1 -0
- package/dist/Tooltip/utils.js +46 -1
- package/dist/Tooltip/utils.js.map +1 -0
- package/dist/cjs/Drawer/Drawer.js +26 -13
- package/dist/cjs/Drawer/index.js +16 -17
- package/dist/cjs/EChart.js +114 -89
- package/dist/cjs/ErrorAlert.js +16 -12
- package/dist/cjs/ErrorBoundary.js +10 -6
- package/dist/cjs/GaugeChart/GaugeChart.js +90 -57
- package/dist/cjs/GaugeChart/index.js +16 -17
- package/dist/cjs/InfoTooltip/InfoTooltip.js +90 -33
- package/dist/cjs/InfoTooltip/InfoTooltip.test.js +27 -17
- package/dist/cjs/InfoTooltip/index.js +16 -17
- package/dist/cjs/LineChart/LineChart.js +122 -87
- package/dist/cjs/LineChart/index.js +16 -17
- package/dist/cjs/LineChart/utils.js +23 -23
- package/dist/cjs/StatChart/StatChart.js +107 -46
- package/dist/cjs/StatChart/StatChart.test.js +65 -21
- package/dist/cjs/StatChart/index.js +16 -17
- package/dist/cjs/TimeRangeSelector/AbsoluteTimePicker.js +144 -64
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +45 -22
- package/dist/cjs/TimeRangeSelector/index.js +17 -18
- package/dist/cjs/TimeRangeSelector/utils.js +19 -16
- package/dist/cjs/Tooltip/SeriesInfo.js +120 -48
- package/dist/cjs/Tooltip/SeriesMarker.js +20 -11
- package/dist/cjs/Tooltip/Tooltip.js +95 -67
- package/dist/cjs/Tooltip/TooltipContent.js +76 -31
- package/dist/cjs/Tooltip/focused-series.js +40 -36
- package/dist/cjs/Tooltip/focused-series.test.js +36 -16
- package/dist/cjs/Tooltip/index.js +17 -18
- package/dist/cjs/Tooltip/tooltip-model.js +46 -30
- package/dist/cjs/Tooltip/utils.js +13 -16
- package/dist/cjs/context/ChartsThemeProvider.js +65 -13
- package/dist/cjs/index.js +27 -28
- package/dist/cjs/model/graph.js +10 -5
- package/dist/cjs/model/index.js +18 -19
- package/dist/cjs/model/theme.js +4 -2
- package/dist/cjs/model/units.js +68 -51
- package/dist/cjs/test/index.js +16 -17
- package/dist/cjs/test/render.js +22 -12
- package/dist/cjs/test/setup-tests.js +4 -2
- package/dist/cjs/utils/combine-sx.js +15 -16
- package/dist/cjs/utils/index.js +17 -18
- package/dist/cjs/utils/theme-gen.js +64 -55
- package/dist/cjs/utils/theme-gen.test.js +14 -12
- package/dist/context/ChartsThemeProvider.js +36 -1
- package/dist/context/ChartsThemeProvider.js.map +1 -0
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -0
- package/dist/model/graph.js +15 -1
- package/dist/model/graph.js.map +1 -0
- package/dist/model/index.js +17 -1
- package/dist/model/index.js.map +1 -0
- package/dist/model/theme.js +15 -1
- package/dist/model/theme.js.map +1 -0
- package/dist/model/units.d.ts.map +1 -1
- package/dist/model/units.js +196 -1
- package/dist/model/units.js.map +1 -0
- package/dist/test/index.js +15 -1
- package/dist/test/index.js.map +1 -0
- package/dist/test/render.js +32 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.js +18 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/utils/combine-sx.js +27 -1
- package/dist/utils/combine-sx.js.map +1 -0
- package/dist/utils/index.js +16 -1
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/theme-gen.js +183 -1
- package/dist/utils/theme-gen.js.map +1 -0
- package/dist/utils/theme-gen.test.js +196 -1
- package/dist/utils/theme-gen.test.js.map +1 -0
- package/package.json +8 -4
package/dist/Tooltip/utils.js
CHANGED
|
@@ -1 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { TOOLTIP_MAX_WIDTH } from './tooltip-model';
|
|
14
|
+
/**
|
|
15
|
+
* Determine position of tooltip depending on chart dimensions and the number of focused series
|
|
16
|
+
*/ export function assembleTransform(mousePos, seriesNum, chartWidth, chartHeight, pinnedPos) {
|
|
17
|
+
if (mousePos === null) {
|
|
18
|
+
return 'translate3d(0, 0)';
|
|
19
|
+
}
|
|
20
|
+
if (pinnedPos !== null) {
|
|
21
|
+
mousePos = pinnedPos;
|
|
22
|
+
}
|
|
23
|
+
const cursorPaddingX = 32;
|
|
24
|
+
const cursorPaddingY = 16;
|
|
25
|
+
const x = mousePos.viewport.x;
|
|
26
|
+
let y = mousePos.viewport.y + cursorPaddingY;
|
|
27
|
+
const isCloseToBottom = mousePos.viewport.y > window.innerHeight * 0.8;
|
|
28
|
+
const yPosAdjustThreshold = chartHeight * 0.75;
|
|
29
|
+
// adjust so tooltip does not get cut off at bottom of chart, reduce multiplier to move up
|
|
30
|
+
if (isCloseToBottom === true) {
|
|
31
|
+
if (seriesNum > 6) {
|
|
32
|
+
y = mousePos.viewport.y * 0.65;
|
|
33
|
+
} else {
|
|
34
|
+
y = mousePos.viewport.y * 0.75;
|
|
35
|
+
}
|
|
36
|
+
} else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {
|
|
37
|
+
y = mousePos.viewport.y * 0.85;
|
|
38
|
+
}
|
|
39
|
+
// use tooltip width to determine when to repos from right to left (width is narrower when only 1 focused series since labels wrap)
|
|
40
|
+
const tooltipWidth = seriesNum > 1 ? TOOLTIP_MAX_WIDTH : TOOLTIP_MAX_WIDTH / 2;
|
|
41
|
+
const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
|
|
42
|
+
// reposition so tooltip is never too close to right side of chart or left side of browser window
|
|
43
|
+
return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)` : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/Tooltip/utils.ts"],"sourcesContent":["// Copyright 2022 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 { CursorCoordinates, CursorData, TOOLTIP_MAX_WIDTH } from './tooltip-model';\n\n/**\n * Determine position of tooltip depending on chart dimensions and the number of focused series\n */\nexport function assembleTransform(\n mousePos: CursorData['coords'],\n seriesNum: number,\n chartWidth: number,\n chartHeight: number,\n pinnedPos: CursorCoordinates | null\n) {\n if (mousePos === null) {\n return 'translate3d(0, 0)';\n }\n\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n }\n\n const cursorPaddingX = 32;\n const cursorPaddingY = 16;\n const x = mousePos.viewport.x;\n let y = mousePos.viewport.y + cursorPaddingY;\n\n const isCloseToBottom = mousePos.viewport.y > window.innerHeight * 0.8;\n const yPosAdjustThreshold = chartHeight * 0.75;\n // adjust so tooltip does not get cut off at bottom of chart, reduce multiplier to move up\n if (isCloseToBottom === true) {\n if (seriesNum > 6) {\n y = mousePos.viewport.y * 0.65;\n } else {\n y = mousePos.viewport.y * 0.75;\n }\n } else if (mousePos.plotCanvas.y > yPosAdjustThreshold) {\n y = mousePos.viewport.y * 0.85;\n }\n\n // use tooltip width to determine when to repos from right to left (width is narrower when only 1 focused series since labels wrap)\n const tooltipWidth = seriesNum > 1 ? TOOLTIP_MAX_WIDTH : TOOLTIP_MAX_WIDTH / 2;\n const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;\n\n // reposition so tooltip is never too close to right side of chart or left side of browser window\n return mousePos.plotCanvas.x > xPosAdjustThreshold && x > TOOLTIP_MAX_WIDTH\n ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)`\n : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;\n}\n"],"names":["TOOLTIP_MAX_WIDTH","assembleTransform","mousePos","seriesNum","chartWidth","chartHeight","pinnedPos","cursorPaddingX","cursorPaddingY","x","viewport","y","isCloseToBottom","window","innerHeight","yPosAdjustThreshold","plotCanvas","tooltipWidth","xPosAdjustThreshold"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAAwCA,iBAAiB,QAAQ,iBAAiB,CAAC;AAEnF;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAC/BC,QAA8B,EAC9BC,SAAiB,EACjBC,UAAkB,EAClBC,WAAmB,EACnBC,SAAmC,EACnC;IACA,IAAIJ,QAAQ,KAAK,IAAI,EAAE;QACrB,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAED,IAAII,SAAS,KAAK,IAAI,EAAE;QACtBJ,QAAQ,GAAGI,SAAS,CAAC;IACvB,CAAC;IAED,MAAMC,cAAc,GAAG,EAAE,AAAC;IAC1B,MAAMC,cAAc,GAAG,EAAE,AAAC;IAC1B,MAAMC,CAAC,GAAGP,QAAQ,CAACQ,QAAQ,CAACD,CAAC,AAAC;IAC9B,IAAIE,CAAC,GAAGT,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAGH,cAAc,AAAC;IAE7C,MAAMI,eAAe,GAAGV,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAGE,MAAM,CAACC,WAAW,GAAG,GAAG,AAAC;IACvE,MAAMC,mBAAmB,GAAGV,WAAW,GAAG,IAAI,AAAC;IAC/C,0FAA0F;IAC1F,IAAIO,eAAe,KAAK,IAAI,EAAE;QAC5B,IAAIT,SAAS,GAAG,CAAC,EAAE;YACjBQ,CAAC,GAAGT,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAG,IAAI,CAAC;QACjC,OAAO;YACLA,CAAC,GAAGT,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAG,IAAI,CAAC;QACjC,CAAC;IACH,OAAO,IAAIT,QAAQ,CAACc,UAAU,CAACL,CAAC,GAAGI,mBAAmB,EAAE;QACtDJ,CAAC,GAAGT,QAAQ,CAACQ,QAAQ,CAACC,CAAC,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,mIAAmI;IACnI,MAAMM,YAAY,GAAGd,SAAS,GAAG,CAAC,GAAGH,iBAAiB,GAAGA,iBAAiB,GAAG,CAAC,AAAC;IAC/E,MAAMkB,mBAAmB,GAAGd,UAAU,GAAGa,YAAY,GAAG,GAAG,AAAC;IAE5D,iGAAiG;IACjG,OAAOf,QAAQ,CAACc,UAAU,CAACP,CAAC,GAAGS,mBAAmB,IAAIT,CAAC,GAAGT,iBAAiB,GACvE,CAAC,YAAY,EAAES,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,wBAAwB,CAAC,GACnE,CAAC,YAAY,EAAEF,CAAC,GAAGF,cAAc,CAAC,IAAI,EAAEI,CAAC,CAAC,MAAM,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Drawer = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
1
|
// Copyright 2022 The Perses Authors
|
|
6
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -14,15 +10,32 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
14
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
11
|
// See the License for the specific language governing permissions and
|
|
16
12
|
// limitations under the License.
|
|
17
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "Drawer", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>Drawer
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _utils = require("../utils");
|
|
18
24
|
const DRAWER_DEFAULT_WIDTH = 900;
|
|
19
|
-
const Drawer = ({ anchor =
|
|
20
|
-
return (
|
|
21
|
-
|
|
25
|
+
const Drawer = ({ anchor ='right' , isOpen , onClose , PaperProps , children , ...rest })=>{
|
|
26
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Drawer, {
|
|
27
|
+
...rest,
|
|
28
|
+
open: isOpen,
|
|
29
|
+
onClose: onClose,
|
|
30
|
+
anchor: anchor,
|
|
31
|
+
PaperProps: {
|
|
32
|
+
...PaperProps,
|
|
33
|
+
sx: (0, _utils.combineSx)({
|
|
22
34
|
width: `${DRAWER_DEFAULT_WIDTH}px`,
|
|
23
|
-
padding: (theme)
|
|
24
|
-
overflow: 'hidden'
|
|
25
|
-
},
|
|
26
|
-
},
|
|
35
|
+
padding: (theme)=>theme.spacing(2),
|
|
36
|
+
overflow: 'hidden'
|
|
37
|
+
}, PaperProps === null || PaperProps === void 0 ? void 0 : PaperProps.sx)
|
|
38
|
+
},
|
|
39
|
+
children: children
|
|
40
|
+
});
|
|
27
41
|
};
|
|
28
|
-
exports.Drawer = Drawer;
|
package/dist/cjs/Drawer/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,19 +10,19 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Object.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./Drawer"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
package/dist/cjs/EChart.js
CHANGED
|
@@ -1,33 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.EChart = void 0;
|
|
30
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
1
|
// Copyright 2022 The Perses Authors
|
|
32
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
33
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -40,11 +10,58 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
40
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
41
11
|
// See the License for the specific language governing permissions and
|
|
42
12
|
// limitations under the License.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "EChart", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>EChart
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = /*#__PURE__*/ _interopRequireWildcard(require("react"));
|
|
23
|
+
const _core = require("echarts/core");
|
|
24
|
+
const _material = require("@mui/material");
|
|
25
|
+
const _lodashEs = require("lodash-es");
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
27
|
+
if (typeof WeakMap !== "function") return null;
|
|
28
|
+
var cacheBabelInterop = new WeakMap();
|
|
29
|
+
var cacheNodeInterop = new WeakMap();
|
|
30
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
31
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
32
|
+
})(nodeInterop);
|
|
33
|
+
}
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
35
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
39
|
+
return {
|
|
40
|
+
default: obj
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
44
|
+
if (cache && cache.has(obj)) {
|
|
45
|
+
return cache.get(obj);
|
|
46
|
+
}
|
|
47
|
+
var newObj = {};
|
|
48
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
49
|
+
for(var key in obj){
|
|
50
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
51
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
52
|
+
if (desc && (desc.get || desc.set)) {
|
|
53
|
+
Object.defineProperty(newObj, key, desc);
|
|
54
|
+
} else {
|
|
55
|
+
newObj[key] = obj[key];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
newObj.default = obj;
|
|
60
|
+
if (cache) {
|
|
61
|
+
cache.set(obj, newObj);
|
|
62
|
+
}
|
|
63
|
+
return newObj;
|
|
64
|
+
}
|
|
48
65
|
const mouseEvents = [
|
|
49
66
|
'click',
|
|
50
67
|
'dblclick',
|
|
@@ -54,100 +71,108 @@ const mouseEvents = [
|
|
|
54
71
|
'mouseover',
|
|
55
72
|
'mouseout',
|
|
56
73
|
'globalout',
|
|
57
|
-
'contextmenu'
|
|
74
|
+
'contextmenu'
|
|
75
|
+
];
|
|
76
|
+
const batchEvents = [
|
|
77
|
+
'datazoom',
|
|
78
|
+
'downplay',
|
|
79
|
+
'highlight'
|
|
58
80
|
];
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const chartElement = (0, react_1.useRef)(null);
|
|
81
|
+
const EChart = /*#__PURE__*/ _react.default.memo(function EChart({ option , theme , renderer , sx , onEvents , _instance , onChartInitialized }) {
|
|
82
|
+
const initialOption = (0, _react.useRef)(option);
|
|
83
|
+
const prevOption = (0, _react.useRef)(option);
|
|
84
|
+
const containerRef = (0, _react.useRef)(null);
|
|
85
|
+
const chartElement = (0, _react.useRef)(null);
|
|
65
86
|
// Initialize chart, dispose on unmount
|
|
66
|
-
(0,
|
|
67
|
-
if (containerRef.current === null || chartElement.current !== null)
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
(0, _react.useLayoutEffect)(()=>{
|
|
88
|
+
if (containerRef.current === null || chartElement.current !== null) return;
|
|
89
|
+
chartElement.current = (0, _core.init)(containerRef.current, theme, {
|
|
90
|
+
renderer: renderer !== null && renderer !== void 0 ? renderer : 'canvas'
|
|
91
|
+
});
|
|
70
92
|
chartElement.current.setOption(initialOption.current, true);
|
|
71
93
|
onChartInitialized === null || onChartInitialized === void 0 ? void 0 : onChartInitialized(chartElement.current);
|
|
72
94
|
if (_instance !== undefined) {
|
|
73
95
|
_instance.current = chartElement.current;
|
|
74
96
|
}
|
|
75
|
-
return ()
|
|
76
|
-
if (chartElement.current === null)
|
|
77
|
-
return;
|
|
97
|
+
return ()=>{
|
|
98
|
+
if (chartElement.current === null) return;
|
|
78
99
|
chartElement.current.dispose();
|
|
79
100
|
chartElement.current = null;
|
|
80
101
|
};
|
|
81
|
-
}, [
|
|
102
|
+
}, [
|
|
103
|
+
_instance,
|
|
104
|
+
onChartInitialized,
|
|
105
|
+
theme,
|
|
106
|
+
renderer
|
|
107
|
+
]);
|
|
82
108
|
// Update chart data when option changes
|
|
83
|
-
(0,
|
|
84
|
-
if (prevOption.current === undefined || (0,
|
|
85
|
-
|
|
86
|
-
if (chartElement.current === null)
|
|
87
|
-
return;
|
|
109
|
+
(0, _react.useEffect)(()=>{
|
|
110
|
+
if (prevOption.current === undefined || (0, _lodashEs.isEqual)(prevOption.current, option)) return;
|
|
111
|
+
if (chartElement.current === null) return;
|
|
88
112
|
chartElement.current.setOption(option, true);
|
|
89
113
|
prevOption.current = option;
|
|
90
|
-
}, [
|
|
114
|
+
}, [
|
|
115
|
+
option
|
|
116
|
+
]);
|
|
91
117
|
// Resize chart, cleanup listener on unmount
|
|
92
|
-
(0,
|
|
93
|
-
const updateSize = (0,
|
|
94
|
-
if (chartElement.current === null)
|
|
95
|
-
return;
|
|
118
|
+
(0, _react.useLayoutEffect)(()=>{
|
|
119
|
+
const updateSize = (0, _lodashEs.debounce)(()=>{
|
|
120
|
+
if (chartElement.current === null) return;
|
|
96
121
|
chartElement.current.resize();
|
|
97
122
|
}, 200);
|
|
98
123
|
window.addEventListener('resize', updateSize);
|
|
99
124
|
updateSize();
|
|
100
|
-
return ()
|
|
125
|
+
return ()=>{
|
|
101
126
|
window.removeEventListener('resize', updateSize);
|
|
102
127
|
};
|
|
103
128
|
}, []);
|
|
104
129
|
// Bind and unbind chart events passed as prop
|
|
105
|
-
(0,
|
|
130
|
+
(0, _react.useEffect)(()=>{
|
|
106
131
|
const chart = chartElement.current;
|
|
107
|
-
if (chart === null || onEvents === undefined)
|
|
108
|
-
return;
|
|
132
|
+
if (chart === null || onEvents === undefined) return;
|
|
109
133
|
bindEvents(chart, onEvents);
|
|
110
|
-
return ()
|
|
111
|
-
if (chart === undefined)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return;
|
|
115
|
-
for (const event in onEvents) {
|
|
134
|
+
return ()=>{
|
|
135
|
+
if (chart === undefined) return;
|
|
136
|
+
if (chart.isDisposed() === true) return;
|
|
137
|
+
for(const event in onEvents){
|
|
116
138
|
chart.off(event);
|
|
117
139
|
}
|
|
118
140
|
};
|
|
119
|
-
}, [
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
141
|
+
}, [
|
|
142
|
+
onEvents
|
|
143
|
+
]);
|
|
144
|
+
(0, _react.useEffect)(()=>{
|
|
145
|
+
const updateSize = (0, _lodashEs.debounce)(()=>{
|
|
146
|
+
if (chartElement.current === null) return;
|
|
124
147
|
chartElement.current.resize();
|
|
125
148
|
}, 200);
|
|
126
149
|
updateSize();
|
|
127
|
-
}, [
|
|
128
|
-
|
|
150
|
+
}, [
|
|
151
|
+
sx
|
|
152
|
+
]);
|
|
153
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Box, {
|
|
154
|
+
ref: containerRef,
|
|
155
|
+
sx: sx
|
|
156
|
+
});
|
|
129
157
|
});
|
|
130
158
|
// Validate event config and bind custom events
|
|
131
159
|
function bindEvents(instance, events) {
|
|
132
|
-
|
|
133
|
-
if (events === undefined)
|
|
134
|
-
return;
|
|
160
|
+
if (events === undefined) return;
|
|
135
161
|
function bindEvent(eventName, OnEventFunction) {
|
|
136
162
|
if (typeof OnEventFunction === 'function') {
|
|
137
163
|
if (isMouseEvent(eventName)) {
|
|
138
|
-
instance.on(eventName, (params)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
else {
|
|
144
|
-
instance.on(eventName, () => OnEventFunction(null, instance));
|
|
164
|
+
instance.on(eventName, (params)=>OnEventFunction(params, instance));
|
|
165
|
+
} else if (isBatchEvent(eventName)) {
|
|
166
|
+
instance.on(eventName, (params)=>OnEventFunction(params));
|
|
167
|
+
} else {
|
|
168
|
+
instance.on(eventName, ()=>OnEventFunction(null, instance));
|
|
145
169
|
}
|
|
146
170
|
}
|
|
147
171
|
}
|
|
148
|
-
for
|
|
172
|
+
for(const eventName in events){
|
|
149
173
|
if (Object.prototype.hasOwnProperty.call(events, eventName)) {
|
|
150
|
-
|
|
174
|
+
var _eventName;
|
|
175
|
+
const customEvent = (_eventName = events[eventName]) !== null && _eventName !== void 0 ? _eventName : null;
|
|
151
176
|
if (customEvent) {
|
|
152
177
|
bindEvent(eventName, customEvent);
|
|
153
178
|
}
|
package/dist/cjs/ErrorAlert.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorAlert = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
6
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
3
|
// you may not use this file except in compliance with the License.
|
|
8
4
|
// You may obtain a copy of the License at
|
|
@@ -14,12 +10,20 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
14
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
11
|
// See the License for the specific language governing permissions and
|
|
16
12
|
// limitations under the License.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "ErrorAlert", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>ErrorAlert
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
21
23
|
function ErrorAlert(props) {
|
|
22
|
-
const { error
|
|
23
|
-
return (0,
|
|
24
|
+
const { error } = props;
|
|
25
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Alert, {
|
|
26
|
+
severity: "error",
|
|
27
|
+
children: error.message
|
|
28
|
+
});
|
|
24
29
|
}
|
|
25
|
-
exports.ErrorAlert = ErrorAlert;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,8 +10,13 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.ErrorBoundary = void 0;
|
|
16
13
|
// Just use react-error-boundary as-is for now
|
|
17
|
-
|
|
18
|
-
Object.defineProperty(exports, "
|
|
14
|
+
"use strict";
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "ErrorBoundary", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: ()=>_reactErrorBoundary.ErrorBoundary
|
|
21
|
+
});
|
|
22
|
+
const _reactErrorBoundary = require("react-error-boundary");
|