@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.
Files changed (131) hide show
  1. package/dist/Drawer/Drawer.d.ts +3 -4
  2. package/dist/Drawer/Drawer.d.ts.map +1 -1
  3. package/dist/Drawer/Drawer.js +35 -1
  4. package/dist/Drawer/Drawer.js.map +1 -0
  5. package/dist/Drawer/index.js +15 -1
  6. package/dist/Drawer/index.js.map +1 -0
  7. package/dist/EChart.d.ts.map +1 -1
  8. package/dist/EChart.js +142 -1
  9. package/dist/EChart.js.map +1 -0
  10. package/dist/ErrorAlert.js +25 -1
  11. package/dist/ErrorAlert.js.map +1 -0
  12. package/dist/ErrorBoundary.js +16 -1
  13. package/dist/ErrorBoundary.js.map +1 -0
  14. package/dist/GaugeChart/GaugeChart.js +172 -1
  15. package/dist/GaugeChart/GaugeChart.js.map +1 -0
  16. package/dist/GaugeChart/index.js +15 -1
  17. package/dist/GaugeChart/index.js.map +1 -0
  18. package/dist/InfoTooltip/InfoTooltip.js +79 -1
  19. package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
  20. package/dist/InfoTooltip/InfoTooltip.test.js +36 -1
  21. package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
  22. package/dist/InfoTooltip/index.js +15 -1
  23. package/dist/InfoTooltip/index.js.map +1 -0
  24. package/dist/LineChart/LineChart.js +198 -1
  25. package/dist/LineChart/LineChart.js.map +1 -0
  26. package/dist/LineChart/index.js +15 -1
  27. package/dist/LineChart/index.js.map +1 -0
  28. package/dist/LineChart/utils.js +63 -1
  29. package/dist/LineChart/utils.js.map +1 -0
  30. package/dist/StatChart/StatChart.js +121 -1
  31. package/dist/StatChart/StatChart.js.map +1 -0
  32. package/dist/StatChart/StatChart.test.js +82 -1
  33. package/dist/StatChart/StatChart.test.js.map +1 -0
  34. package/dist/StatChart/index.js +15 -1
  35. package/dist/StatChart/index.js.map +1 -0
  36. package/dist/TimeRangeSelector/AbsoluteTimePicker.js +175 -1
  37. package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +1 -0
  38. package/dist/TimeRangeSelector/TimeRangeSelector.js +52 -1
  39. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
  40. package/dist/TimeRangeSelector/index.js +16 -1
  41. package/dist/TimeRangeSelector/index.js.map +1 -0
  42. package/dist/TimeRangeSelector/utils.js +36 -1
  43. package/dist/TimeRangeSelector/utils.js.map +1 -0
  44. package/dist/Tooltip/SeriesInfo.js +143 -1
  45. package/dist/Tooltip/SeriesInfo.js.map +1 -0
  46. package/dist/Tooltip/SeriesMarker.js +33 -1
  47. package/dist/Tooltip/SeriesMarker.js.map +1 -0
  48. package/dist/Tooltip/Tooltip.js +72 -1
  49. package/dist/Tooltip/Tooltip.js.map +1 -0
  50. package/dist/Tooltip/TooltipContent.js +89 -1
  51. package/dist/Tooltip/TooltipContent.js.map +1 -0
  52. package/dist/Tooltip/focused-series.js +108 -1
  53. package/dist/Tooltip/focused-series.js.map +1 -0
  54. package/dist/Tooltip/focused-series.test.js +75 -1
  55. package/dist/Tooltip/focused-series.test.js.map +1 -0
  56. package/dist/Tooltip/index.js +16 -1
  57. package/dist/Tooltip/index.js.map +1 -0
  58. package/dist/Tooltip/tooltip-model.js +80 -1
  59. package/dist/Tooltip/tooltip-model.js.map +1 -0
  60. package/dist/Tooltip/utils.js +46 -1
  61. package/dist/Tooltip/utils.js.map +1 -0
  62. package/dist/cjs/Drawer/Drawer.js +26 -13
  63. package/dist/cjs/Drawer/index.js +16 -17
  64. package/dist/cjs/EChart.js +114 -89
  65. package/dist/cjs/ErrorAlert.js +16 -12
  66. package/dist/cjs/ErrorBoundary.js +10 -6
  67. package/dist/cjs/GaugeChart/GaugeChart.js +90 -57
  68. package/dist/cjs/GaugeChart/index.js +16 -17
  69. package/dist/cjs/InfoTooltip/InfoTooltip.js +90 -33
  70. package/dist/cjs/InfoTooltip/InfoTooltip.test.js +27 -17
  71. package/dist/cjs/InfoTooltip/index.js +16 -17
  72. package/dist/cjs/LineChart/LineChart.js +122 -87
  73. package/dist/cjs/LineChart/index.js +16 -17
  74. package/dist/cjs/LineChart/utils.js +23 -23
  75. package/dist/cjs/StatChart/StatChart.js +107 -46
  76. package/dist/cjs/StatChart/StatChart.test.js +65 -21
  77. package/dist/cjs/StatChart/index.js +16 -17
  78. package/dist/cjs/TimeRangeSelector/AbsoluteTimePicker.js +144 -64
  79. package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +45 -22
  80. package/dist/cjs/TimeRangeSelector/index.js +17 -18
  81. package/dist/cjs/TimeRangeSelector/utils.js +19 -16
  82. package/dist/cjs/Tooltip/SeriesInfo.js +120 -48
  83. package/dist/cjs/Tooltip/SeriesMarker.js +20 -11
  84. package/dist/cjs/Tooltip/Tooltip.js +95 -67
  85. package/dist/cjs/Tooltip/TooltipContent.js +76 -31
  86. package/dist/cjs/Tooltip/focused-series.js +40 -36
  87. package/dist/cjs/Tooltip/focused-series.test.js +36 -16
  88. package/dist/cjs/Tooltip/index.js +17 -18
  89. package/dist/cjs/Tooltip/tooltip-model.js +46 -30
  90. package/dist/cjs/Tooltip/utils.js +13 -16
  91. package/dist/cjs/context/ChartsThemeProvider.js +65 -13
  92. package/dist/cjs/index.js +27 -28
  93. package/dist/cjs/model/graph.js +10 -5
  94. package/dist/cjs/model/index.js +18 -19
  95. package/dist/cjs/model/theme.js +4 -2
  96. package/dist/cjs/model/units.js +68 -51
  97. package/dist/cjs/test/index.js +16 -17
  98. package/dist/cjs/test/render.js +22 -12
  99. package/dist/cjs/test/setup-tests.js +4 -2
  100. package/dist/cjs/utils/combine-sx.js +15 -16
  101. package/dist/cjs/utils/index.js +17 -18
  102. package/dist/cjs/utils/theme-gen.js +64 -55
  103. package/dist/cjs/utils/theme-gen.test.js +14 -12
  104. package/dist/context/ChartsThemeProvider.js +36 -1
  105. package/dist/context/ChartsThemeProvider.js.map +1 -0
  106. package/dist/index.js +26 -1
  107. package/dist/index.js.map +1 -0
  108. package/dist/model/graph.js +15 -1
  109. package/dist/model/graph.js.map +1 -0
  110. package/dist/model/index.js +17 -1
  111. package/dist/model/index.js.map +1 -0
  112. package/dist/model/theme.js +15 -1
  113. package/dist/model/theme.js.map +1 -0
  114. package/dist/model/units.d.ts.map +1 -1
  115. package/dist/model/units.js +196 -1
  116. package/dist/model/units.js.map +1 -0
  117. package/dist/test/index.js +15 -1
  118. package/dist/test/index.js.map +1 -0
  119. package/dist/test/render.js +32 -1
  120. package/dist/test/render.js.map +1 -0
  121. package/dist/test/setup-tests.js +18 -1
  122. package/dist/test/setup-tests.js.map +1 -0
  123. package/dist/utils/combine-sx.js +27 -1
  124. package/dist/utils/combine-sx.js.map +1 -0
  125. package/dist/utils/index.js +16 -1
  126. package/dist/utils/index.js.map +1 -0
  127. package/dist/utils/theme-gen.js +183 -1
  128. package/dist/utils/theme-gen.js.map +1 -0
  129. package/dist/utils/theme-gen.test.js +196 -1
  130. package/dist/utils/theme-gen.test.js.map +1 -0
  131. package/package.json +8 -4
@@ -1 +1,46 @@
1
- import{TOOLTIP_MAX_WIDTH}from"./tooltip-model";export function assembleTransform(t,o,r,e,n){if(null===t)return"translate3d(0, 0)";null!==n&&(t=n);const p=t.viewport.x;let a=t.viewport.y+16;const l=.75*e;!0==t.viewport.y>.8*window.innerHeight?a=o>6?.65*t.viewport.y:.75*t.viewport.y:t.plotCanvas.y>l&&(a=.85*t.viewport.y);const i=r-.9*(o>1?TOOLTIP_MAX_WIDTH:TOOLTIP_MAX_WIDTH/2);return t.plotCanvas.x>i&&p>TOOLTIP_MAX_WIDTH?`translate3d(${p-32}px, ${a}px, 0) translateX(-100%)`:`translate3d(${p+32}px, ${a}px, 0)`}
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
- const material_1 = require("@mui/material");
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 = 'right', isOpen, onClose, children }) => {
20
- return ((0, jsx_runtime_1.jsx)(material_1.Drawer, { open: isOpen, onClose: onClose, anchor: anchor, PaperProps: {
21
- sx: {
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) => theme.spacing(2),
24
- overflow: 'hidden',
25
- },
26
- }, children: children }));
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;
@@ -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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
- if (k2 === undefined) k2 = k;
16
- var desc = Object.getOwnPropertyDescriptor(m, k);
17
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
- desc = { enumerable: true, get: function() { return m[k]; } };
19
- }
20
- Object.defineProperty(o, k2, desc);
21
- }) : (function(o, m, k, k2) {
22
- if (k2 === undefined) k2 = k;
23
- o[k2] = m[k];
24
- }));
25
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- __exportStar(require("./Drawer"), exports);
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
+ }
@@ -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
- const react_1 = __importStar(require("react"));
44
- const debounce_1 = __importDefault(require("lodash/debounce"));
45
- const core_1 = require("echarts/core");
46
- const material_1 = require("@mui/material");
47
- const lodash_es_1 = require("lodash-es");
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 batchEvents = ['datazoom', 'downplay', 'highlight'];
60
- exports.EChart = react_1.default.memo(function EChart({ option, theme, renderer, sx, onEvents, _instance, onChartInitialized, }) {
61
- const initialOption = (0, react_1.useRef)(option);
62
- const prevOption = (0, react_1.useRef)(option);
63
- const containerRef = (0, react_1.useRef)(null);
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, react_1.useLayoutEffect)(() => {
67
- if (containerRef.current === null || chartElement.current !== null)
68
- return;
69
- chartElement.current = (0, core_1.init)(containerRef.current, theme, { renderer: renderer !== null && renderer !== void 0 ? renderer : 'canvas' });
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
- }, [_instance, onChartInitialized, theme, renderer]);
102
+ }, [
103
+ _instance,
104
+ onChartInitialized,
105
+ theme,
106
+ renderer
107
+ ]);
82
108
  // Update chart data when option changes
83
- (0, react_1.useEffect)(() => {
84
- if (prevOption.current === undefined || (0, lodash_es_1.isEqual)(prevOption.current, option))
85
- return;
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
- }, [option]);
114
+ }, [
115
+ option
116
+ ]);
91
117
  // Resize chart, cleanup listener on unmount
92
- (0, react_1.useLayoutEffect)(() => {
93
- const updateSize = (0, debounce_1.default)(() => {
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, react_1.useEffect)(() => {
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
- return;
113
- if (chart.isDisposed() === true)
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
- }, [onEvents]);
120
- (0, react_1.useEffect)(() => {
121
- const updateSize = (0, debounce_1.default)(() => {
122
- if (chartElement.current === null)
123
- return;
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
- }, [sx]);
128
- return (0, jsx_runtime_1.jsx)(material_1.Box, { ref: containerRef, sx: sx });
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
- var _a;
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) => OnEventFunction(params, instance));
139
- }
140
- else if (isBatchEvent(eventName)) {
141
- instance.on(eventName, (params) => OnEventFunction(params));
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 (const eventName in events) {
172
+ for(const eventName in events){
149
173
  if (Object.prototype.hasOwnProperty.call(events, eventName)) {
150
- const customEvent = (_a = events[eventName]) !== null && _a !== void 0 ? _a : null;
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
  }
@@ -1,8 +1,4 @@
1
- "use strict";
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
- const material_1 = require("@mui/material");
18
- /**
19
- * Shows an MUI Alert with the `Error.message` as its contents.
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 } = props;
23
- return (0, jsx_runtime_1.jsx)(material_1.Alert, { severity: "error", children: error.message });
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
- "use strict";
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
- var react_error_boundary_1 = require("react-error-boundary");
18
- Object.defineProperty(exports, "ErrorBoundary", { enumerable: true, get: function () { return react_error_boundary_1.ErrorBoundary; } });
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");