@perses-dev/components 0.51.0-beta.1 → 0.51.0-rc.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 (52) hide show
  1. package/dist/EChart/EChart.d.ts +3 -2
  2. package/dist/EChart/EChart.d.ts.map +1 -1
  3. package/dist/EChart/EChart.js +8 -5
  4. package/dist/EChart/EChart.js.map +1 -1
  5. package/dist/JSONEditor.d.ts.map +1 -1
  6. package/dist/JSONEditor.js +5 -6
  7. package/dist/JSONEditor.js.map +1 -1
  8. package/dist/StatChart/StatChart.d.ts.map +1 -1
  9. package/dist/StatChart/StatChart.js +6 -2
  10. package/dist/StatChart/StatChart.js.map +1 -1
  11. package/dist/Table/Table.d.ts +1 -1
  12. package/dist/Table/Table.d.ts.map +1 -1
  13. package/dist/Table/Table.js +14 -4
  14. package/dist/Table/Table.js.map +1 -1
  15. package/dist/Table/TableFoot.d.ts +4 -0
  16. package/dist/Table/TableFoot.d.ts.map +1 -0
  17. package/dist/Table/TableFoot.js +23 -0
  18. package/dist/Table/TableFoot.js.map +1 -0
  19. package/dist/Table/VirtualizedTable.d.ts +3 -2
  20. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  21. package/dist/Table/VirtualizedTable.js +31 -2
  22. package/dist/Table/VirtualizedTable.js.map +1 -1
  23. package/dist/Table/model/table-model.d.ts +10 -1
  24. package/dist/Table/model/table-model.d.ts.map +1 -1
  25. package/dist/Table/model/table-model.js.map +1 -1
  26. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
  27. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  28. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  29. package/dist/TimeSeriesTooltip/LineChartTooltip.js +2 -5
  30. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  31. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  32. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +2 -5
  33. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  34. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +1 -8
  35. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  36. package/dist/TimeSeriesTooltip/tooltip-model.js +6 -16
  37. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  38. package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
  39. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  40. package/dist/TimeSeriesTooltip/utils.js +27 -23
  41. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  42. package/dist/cjs/EChart/EChart.js +7 -4
  43. package/dist/cjs/JSONEditor.js +4 -5
  44. package/dist/cjs/StatChart/StatChart.js +6 -2
  45. package/dist/cjs/Table/Table.js +13 -3
  46. package/dist/cjs/Table/TableFoot.js +31 -0
  47. package/dist/cjs/Table/VirtualizedTable.js +30 -1
  48. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +1 -4
  49. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +1 -4
  50. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +6 -25
  51. package/dist/cjs/TimeSeriesTooltip/utils.js +26 -22
  52. package/package.json +2 -2
@@ -10,10 +10,10 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { TOOLTIP_MAX_WIDTH, TOOLTIP_MAX_HEIGHT, TOOLTIP_MIN_WIDTH, TOOLTIP_ADJUST_Y_POS_MULTIPLIER, TOOLTIP_BG_COLOR_FALLBACK, TOOLTIP_PADDING } from './tooltip-model';
13
+ import { TOOLTIP_MAX_WIDTH, TOOLTIP_MAX_HEIGHT, TOOLTIP_MIN_WIDTH, TOOLTIP_BG_COLOR_FALLBACK, TOOLTIP_PADDING } from './tooltip-model';
14
14
  /**
15
15
  * Determine position of tooltip depending on chart dimensions and the number of focused series
16
- */ export function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth, containerElement) {
16
+ */ export function assembleTransform(mousePos, pinnedPos, tooltipHeight, tooltipWidth, containerElement) {
17
17
  if (mousePos === null) {
18
18
  return undefined;
19
19
  }
@@ -23,33 +23,37 @@ import { TOOLTIP_MAX_WIDTH, TOOLTIP_MAX_HEIGHT, TOOLTIP_MIN_WIDTH, TOOLTIP_ADJUS
23
23
  mousePos = pinnedPos;
24
24
  }
25
25
  if (mousePos.plotCanvas.x === undefined) return undefined;
26
- // By default, tooltip is located in a Portal attached to the body.
27
- // Using page coordinates instead of viewport ensures the tooltip is
28
- // absolutely positioned correctly as the user scrolls
29
- let x = mousePos.page.x;
26
+ let x = mousePos.page.x + cursorPaddingX; // Default to right side of the cursor
30
27
  let y = mousePos.page.y + cursorPaddingY;
31
- // If containerElement is defined, tooltip is attached to the containerElement instead.
32
- let containerRect;
28
+ // If containerElement is defined, adjust coordinates relative to the container
33
29
  if (containerElement) {
34
- // get the container's position relative to viewport
35
- containerRect = containerElement.getBoundingClientRect();
36
- // calculate the mouse position relative to container
30
+ const containerRect = containerElement.getBoundingClientRect();
37
31
  x = x - containerRect.left + containerElement.scrollLeft;
38
32
  y = y - containerRect.top + containerElement.scrollTop;
39
- }
40
- if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {
41
- // adjust so tooltip does not get cut off at bottom of chart
42
- // multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport
43
- y = y - tooltipHeight * TOOLTIP_ADJUST_Y_POS_MULTIPLIER;
44
- // If y is now above of the top of containerElement, set y close to 0 so tooltip does not get cut off
45
- if (containerRect && y < containerRect.top) {
46
- y = TOOLTIP_PADDING / 2; // leaves room for some padding around tooltip
33
+ // Ensure tooltip does not go out of the container's bottom
34
+ const containerBottom = containerRect.top + containerElement.scrollHeight;
35
+ if (y + tooltipHeight > containerBottom) {
36
+ y = Math.max(containerBottom - tooltipHeight - cursorPaddingY, TOOLTIP_PADDING / 2);
37
+ }
38
+ } else {
39
+ // Ensure tooltip does not go out of the screen on the bottom
40
+ if (y + tooltipHeight > window.innerHeight + window.scrollY) {
41
+ y = Math.max(window.innerHeight + window.scrollY - tooltipHeight - cursorPaddingY, TOOLTIP_PADDING / 2);
47
42
  }
48
43
  }
49
- // use tooltip width to determine when to repos from right to left
50
- const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
51
- // reposition so tooltip is never too close to right side of chart or left side of browser window
52
- 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
+ // Ensure tooltip does not go out of the screen on the right
45
+ if (x + tooltipWidth > window.innerWidth) {
46
+ x = mousePos.page.x - tooltipWidth - cursorPaddingX; // Move to the left of the cursor
47
+ }
48
+ // Ensure tooltip does not go out of the screen on the left
49
+ if (x < cursorPaddingX) {
50
+ x = cursorPaddingX;
51
+ }
52
+ // Ensure tooltip does not go out of the screen on the top
53
+ if (y < TOOLTIP_PADDING / 2) {
54
+ y = TOOLTIP_PADDING / 2;
55
+ }
56
+ return `translate3d(${x}px, ${y}px, 0)`;
53
57
  }
54
58
  /**
55
59
  * Helper for tooltip positioning styles
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/utils.ts"],"sourcesContent":["// Copyright 2023 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 { Theme } from '@mui/material';\nimport {\n CursorCoordinates,\n CursorData,\n TOOLTIP_MAX_WIDTH,\n TOOLTIP_MAX_HEIGHT,\n TOOLTIP_MIN_WIDTH,\n TOOLTIP_ADJUST_Y_POS_MULTIPLIER,\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_PADDING,\n} 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 chartWidth: number,\n pinnedPos: CursorCoordinates | null,\n tooltipHeight: number,\n tooltipWidth: number,\n containerElement?: Element | null\n): string | undefined {\n if (mousePos === null) {\n return undefined;\n }\n\n const cursorPaddingX = 32;\n const cursorPaddingY = 16;\n\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n }\n\n if (mousePos.plotCanvas.x === undefined) return undefined;\n\n // By default, tooltip is located in a Portal attached to the body.\n // Using page coordinates instead of viewport ensures the tooltip is\n // absolutely positioned correctly as the user scrolls\n let x = mousePos.page.x;\n let y = mousePos.page.y + cursorPaddingY;\n\n // If containerElement is defined, tooltip is attached to the containerElement instead.\n let containerRect;\n if (containerElement) {\n // get the container's position relative to viewport\n containerRect = containerElement.getBoundingClientRect();\n // calculate the mouse position relative to container\n x = x - containerRect.left + containerElement.scrollLeft;\n y = y - containerRect.top + containerElement.scrollTop;\n }\n\n if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {\n // adjust so tooltip does not get cut off at bottom of chart\n // multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport\n y = y - tooltipHeight * TOOLTIP_ADJUST_Y_POS_MULTIPLIER;\n\n // If y is now above of the top of containerElement, set y close to 0 so tooltip does not get cut off\n if (containerRect && y < containerRect.top) {\n y = TOOLTIP_PADDING / 2; // leaves room for some padding around tooltip\n }\n }\n\n // use tooltip width to determine when to repos from right to left\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\n/**\n * Helper for tooltip positioning styles\n */\nexport function getTooltipStyles(\n theme: Theme,\n pinnedPos: CursorCoordinates | null,\n maxHeight?: number\n): Record<string, unknown> {\n const adjustedMaxHeight = maxHeight ? maxHeight - TOOLTIP_PADDING : undefined;\n return {\n minWidth: TOOLTIP_MIN_WIDTH,\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: adjustedMaxHeight ?? TOOLTIP_MAX_HEIGHT,\n padding: 0,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n // Ensure pinned tooltip shows behind edit panel drawer and sticky header\n zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n };\n}\n"],"names":["TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_MIN_WIDTH","TOOLTIP_ADJUST_Y_POS_MULTIPLIER","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_PADDING","assembleTransform","mousePos","chartWidth","pinnedPos","tooltipHeight","tooltipWidth","containerElement","undefined","cursorPaddingX","cursorPaddingY","plotCanvas","x","page","y","containerRect","getBoundingClientRect","left","scrollLeft","top","scrollTop","client","window","innerHeight","xPosAdjustThreshold","getTooltipStyles","theme","maxHeight","adjustedMaxHeight","minWidth","maxWidth","padding","position","backgroundColor","palette","designSystem","grey","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY"],"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;AAGjC,SAGEA,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,+BAA+B,EAC/BC,yBAAyB,EACzBC,eAAe,QACV,kBAAkB;AAEzB;;CAEC,GACD,OAAO,SAASC,kBACdC,QAA8B,EAC9BC,UAAkB,EAClBC,SAAmC,EACnCC,aAAqB,EACrBC,YAAoB,EACpBC,gBAAiC;IAEjC,IAAIL,aAAa,MAAM;QACrB,OAAOM;IACT;IAEA,MAAMC,iBAAiB;IACvB,MAAMC,iBAAiB;IAEvB,IAAIN,cAAc,MAAM;QACtBF,WAAWE;IACb;IAEA,IAAIF,SAASS,UAAU,CAACC,CAAC,KAAKJ,WAAW,OAAOA;IAEhD,mEAAmE;IACnE,oEAAoE;IACpE,sDAAsD;IACtD,IAAII,IAAIV,SAASW,IAAI,CAACD,CAAC;IACvB,IAAIE,IAAIZ,SAASW,IAAI,CAACC,CAAC,GAAGJ;IAE1B,uFAAuF;IACvF,IAAIK;IACJ,IAAIR,kBAAkB;QACpB,oDAAoD;QACpDQ,gBAAgBR,iBAAiBS,qBAAqB;QACtD,qDAAqD;QACrDJ,IAAIA,IAAIG,cAAcE,IAAI,GAAGV,iBAAiBW,UAAU;QACxDJ,IAAIA,IAAIC,cAAcI,GAAG,GAAGZ,iBAAiBa,SAAS;IACxD;IAEA,IAAIlB,SAASmB,MAAM,CAACP,CAAC,GAAGT,gBAAgBK,iBAAiBY,OAAOC,WAAW,EAAE;QAC3E,4DAA4D;QAC5D,+FAA+F;QAC/FT,IAAIA,IAAIT,gBAAgBP;QAExB,qGAAqG;QACrG,IAAIiB,iBAAiBD,IAAIC,cAAcI,GAAG,EAAE;YAC1CL,IAAId,kBAAkB,GAAG,8CAA8C;QACzE;IACF;IAEA,kEAAkE;IAClE,MAAMwB,sBAAsBrB,aAAaG,eAAe;IAExD,iGAAiG;IACjG,OAAOJ,SAASS,UAAU,CAACC,CAAC,GAAGY,uBAAuBZ,IAAIjB,oBACtD,CAAC,YAAY,EAAEiB,IAAIH,eAAe,IAAI,EAAEK,EAAE,wBAAwB,CAAC,GACnE,CAAC,YAAY,EAAEF,IAAIH,eAAe,IAAI,EAAEK,EAAE,MAAM,CAAC;AACvD;AAEA;;CAEC,GACD,OAAO,SAASW,iBACdC,KAAY,EACZtB,SAAmC,EACnCuB,SAAkB;IAElB,MAAMC,oBAAoBD,YAAYA,YAAY3B,kBAAkBQ;IACpE,OAAO;QACLqB,UAAUhC;QACViC,UAAUnC;QACVgC,WAAWC,qBAAqBhC;QAChCmC,SAAS;QACTC,UAAU;QACVb,KAAK;QACLF,MAAM;QACNgB,iBAAiBP,MAAMQ,OAAO,CAACC,YAAY,EAAEC,IAAI,CAAC,IAAI,IAAIrC;QAC1DsC,cAAc;QACdC,OAAO;QACPC,UAAU;QACVC,YAAY;QACZC,SAAS;QACTC,YAAY;QACZ,yEAAyE;QACzEC,QAAQvC,cAAc,OAAO,SAASsB,MAAMiB,MAAM,CAACC,OAAO;QAC1DC,UAAU;QACV,WAAW;YACTC,WAAW;QACb;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/utils.ts"],"sourcesContent":["// Copyright 2023 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 { Theme } from '@mui/material';\nimport {\n CursorCoordinates,\n CursorData,\n TOOLTIP_MAX_WIDTH,\n TOOLTIP_MAX_HEIGHT,\n TOOLTIP_MIN_WIDTH,\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_PADDING,\n} 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 pinnedPos: CursorCoordinates | null,\n tooltipHeight: number,\n tooltipWidth: number,\n containerElement?: Element | null\n): string | undefined {\n if (mousePos === null) {\n return undefined;\n }\n\n const cursorPaddingX = 32;\n const cursorPaddingY = 16;\n\n if (pinnedPos !== null) {\n mousePos = pinnedPos;\n }\n\n if (mousePos.plotCanvas.x === undefined) return undefined;\n\n let x = mousePos.page.x + cursorPaddingX; // Default to right side of the cursor\n let y = mousePos.page.y + cursorPaddingY;\n\n // If containerElement is defined, adjust coordinates relative to the container\n if (containerElement) {\n const containerRect = containerElement.getBoundingClientRect();\n x = x - containerRect.left + containerElement.scrollLeft;\n y = y - containerRect.top + containerElement.scrollTop;\n\n // Ensure tooltip does not go out of the container's bottom\n const containerBottom = containerRect.top + containerElement.scrollHeight;\n if (y + tooltipHeight > containerBottom) {\n y = Math.max(containerBottom - tooltipHeight - cursorPaddingY, TOOLTIP_PADDING / 2);\n }\n } else {\n // Ensure tooltip does not go out of the screen on the bottom\n if (y + tooltipHeight > window.innerHeight + window.scrollY) {\n y = Math.max(window.innerHeight + window.scrollY - tooltipHeight - cursorPaddingY, TOOLTIP_PADDING / 2);\n }\n }\n\n // Ensure tooltip does not go out of the screen on the right\n if (x + tooltipWidth > window.innerWidth) {\n x = mousePos.page.x - tooltipWidth - cursorPaddingX; // Move to the left of the cursor\n }\n\n // Ensure tooltip does not go out of the screen on the left\n if (x < cursorPaddingX) {\n x = cursorPaddingX;\n }\n\n // Ensure tooltip does not go out of the screen on the top\n if (y < TOOLTIP_PADDING / 2) {\n y = TOOLTIP_PADDING / 2;\n }\n\n return `translate3d(${x}px, ${y}px, 0)`;\n}\n\n/**\n * Helper for tooltip positioning styles\n */\nexport function getTooltipStyles(\n theme: Theme,\n pinnedPos: CursorCoordinates | null,\n maxHeight?: number\n): Record<string, unknown> {\n const adjustedMaxHeight = maxHeight ? maxHeight - TOOLTIP_PADDING : undefined;\n return {\n minWidth: TOOLTIP_MIN_WIDTH,\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: adjustedMaxHeight ?? TOOLTIP_MAX_HEIGHT,\n padding: 0,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n // Ensure pinned tooltip shows behind edit panel drawer and sticky header\n zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n };\n}\n"],"names":["TOOLTIP_MAX_WIDTH","TOOLTIP_MAX_HEIGHT","TOOLTIP_MIN_WIDTH","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_PADDING","assembleTransform","mousePos","pinnedPos","tooltipHeight","tooltipWidth","containerElement","undefined","cursorPaddingX","cursorPaddingY","plotCanvas","x","page","y","containerRect","getBoundingClientRect","left","scrollLeft","top","scrollTop","containerBottom","scrollHeight","Math","max","window","innerHeight","scrollY","innerWidth","getTooltipStyles","theme","maxHeight","adjustedMaxHeight","minWidth","maxWidth","padding","position","backgroundColor","palette","designSystem","grey","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY"],"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;AAGjC,SAGEA,iBAAiB,EACjBC,kBAAkB,EAClBC,iBAAiB,EACjBC,yBAAyB,EACzBC,eAAe,QACV,kBAAkB;AAEzB;;CAEC,GACD,OAAO,SAASC,kBACdC,QAA8B,EAC9BC,SAAmC,EACnCC,aAAqB,EACrBC,YAAoB,EACpBC,gBAAiC;IAEjC,IAAIJ,aAAa,MAAM;QACrB,OAAOK;IACT;IAEA,MAAMC,iBAAiB;IACvB,MAAMC,iBAAiB;IAEvB,IAAIN,cAAc,MAAM;QACtBD,WAAWC;IACb;IAEA,IAAID,SAASQ,UAAU,CAACC,CAAC,KAAKJ,WAAW,OAAOA;IAEhD,IAAII,IAAIT,SAASU,IAAI,CAACD,CAAC,GAAGH,gBAAgB,sCAAsC;IAChF,IAAIK,IAAIX,SAASU,IAAI,CAACC,CAAC,GAAGJ;IAE1B,+EAA+E;IAC/E,IAAIH,kBAAkB;QACpB,MAAMQ,gBAAgBR,iBAAiBS,qBAAqB;QAC5DJ,IAAIA,IAAIG,cAAcE,IAAI,GAAGV,iBAAiBW,UAAU;QACxDJ,IAAIA,IAAIC,cAAcI,GAAG,GAAGZ,iBAAiBa,SAAS;QAEtD,2DAA2D;QAC3D,MAAMC,kBAAkBN,cAAcI,GAAG,GAAGZ,iBAAiBe,YAAY;QACzE,IAAIR,IAAIT,gBAAgBgB,iBAAiB;YACvCP,IAAIS,KAAKC,GAAG,CAACH,kBAAkBhB,gBAAgBK,gBAAgBT,kBAAkB;QACnF;IACF,OAAO;QACL,6DAA6D;QAC7D,IAAIa,IAAIT,gBAAgBoB,OAAOC,WAAW,GAAGD,OAAOE,OAAO,EAAE;YAC3Db,IAAIS,KAAKC,GAAG,CAACC,OAAOC,WAAW,GAAGD,OAAOE,OAAO,GAAGtB,gBAAgBK,gBAAgBT,kBAAkB;QACvG;IACF;IAEA,4DAA4D;IAC5D,IAAIW,IAAIN,eAAemB,OAAOG,UAAU,EAAE;QACxChB,IAAIT,SAASU,IAAI,CAACD,CAAC,GAAGN,eAAeG,gBAAgB,iCAAiC;IACxF;IAEA,2DAA2D;IAC3D,IAAIG,IAAIH,gBAAgB;QACtBG,IAAIH;IACN;IAEA,0DAA0D;IAC1D,IAAIK,IAAIb,kBAAkB,GAAG;QAC3Ba,IAAIb,kBAAkB;IACxB;IAEA,OAAO,CAAC,YAAY,EAAEW,EAAE,IAAI,EAAEE,EAAE,MAAM,CAAC;AACzC;AAEA;;CAEC,GACD,OAAO,SAASe,iBACdC,KAAY,EACZ1B,SAAmC,EACnC2B,SAAkB;IAElB,MAAMC,oBAAoBD,YAAYA,YAAY9B,kBAAkBO;IACpE,OAAO;QACLyB,UAAUlC;QACVmC,UAAUrC;QACVkC,WAAWC,qBAAqBlC;QAChCqC,SAAS;QACTC,UAAU;QACVjB,KAAK;QACLF,MAAM;QACNoB,iBAAiBP,MAAMQ,OAAO,CAACC,YAAY,EAAEC,IAAI,CAAC,IAAI,IAAIxC;QAC1DyC,cAAc;QACdC,OAAO;QACPC,UAAU;QACVC,YAAY;QACZC,SAAS;QACTC,YAAY;QACZ,yEAAyE;QACzEC,QAAQ3C,cAAc,OAAO,SAAS0B,MAAMiB,MAAM,CAACC,OAAO;QAC1DC,UAAU;QACV,WAAW;YACTC,WAAW;QACb;IACF;AACF"}
@@ -34,13 +34,14 @@ function _interop_require_default(obj) {
34
34
  default: obj
35
35
  };
36
36
  }
37
- // Loading the ECharts extensions should happen in the respective plugin (in this case, the scatterplot plugin).
37
+ // Loading the ECharts extensions should happen in the respective plugin (in this case, the scatterplot + custom plugin).
38
38
  // This is a workaround for https://github.com/perses/plugins/issues/83.
39
39
  (0, _core.use)([
40
40
  _components.DatasetComponent,
41
41
  _components.DataZoomComponent,
42
42
  _components.LegendComponent,
43
43
  _charts.ScatterChart,
44
+ _charts.CustomChart,
44
45
  _components.GridComponent,
45
46
  _components.TitleComponent,
46
47
  _components.TooltipComponent,
@@ -62,7 +63,7 @@ const batchEvents = [
62
63
  'downplay',
63
64
  'highlight'
64
65
  ];
65
- const EChart = /*#__PURE__*/ (0, _react.memo)(function EChart({ option, theme, renderer, sx, onEvents, _instance, syncGroup, onChartInitialized }) {
66
+ const EChart = /*#__PURE__*/ (0, _react.memo)(function EChart({ option, theme, renderer, sx, style, onEvents, _instance, syncGroup, onChartInitialized }) {
66
67
  const initialOption = (0, _react.useRef)(option);
67
68
  const prevOption = (0, _react.useRef)(option);
68
69
  const containerRef = (0, _react.useRef)(null);
@@ -152,11 +153,13 @@ const EChart = /*#__PURE__*/ (0, _react.memo)(function EChart({ option, theme, r
152
153
  });
153
154
  updateSize();
154
155
  }, [
155
- sx
156
+ sx,
157
+ style
156
158
  ]);
157
159
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
158
160
  ref: containerRef,
159
- sx: sx
161
+ sx: sx,
162
+ style: style
160
163
  });
161
164
  });
162
165
  // Validate event config and bind custom events
@@ -36,11 +36,6 @@ function JSONEditor(props) {
36
36
  const isDarkMode = theme.palette.mode === 'dark';
37
37
  const [value, setValue] = (0, _react.useState)(()=>JSON.stringify(props.value, null, 2));
38
38
  const [lastProcessedValue, setLastProcessedValue] = (0, _react.useState)(value);
39
- (0, _react.useEffect)(()=>{
40
- setValue(JSON.stringify(props.value, null, 2));
41
- }, [
42
- props.value
43
- ]);
44
39
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactcodemirror.default, {
45
40
  ...props,
46
41
  style: {
@@ -55,6 +50,10 @@ function JSONEditor(props) {
55
50
  value: value,
56
51
  onChange: (newValue)=>{
57
52
  setValue(newValue);
53
+ // Trigger the provided onChange callback in real-time
54
+ if (props.onChange) {
55
+ props.onChange(newValue);
56
+ }
58
57
  },
59
58
  onBlur: ()=>{
60
59
  // Don't trigger the provided onChange if the last processed value is equal to the current value.
@@ -167,8 +167,12 @@ const StatChart = (props)=>{
167
167
  }),
168
168
  sparkline !== undefined && /*#__PURE__*/ (0, _jsxruntime.jsx)(_EChart.EChart, {
169
169
  sx: {
170
- width: '100%',
171
- height: height - seriesNameHeight - valueFontHeight
170
+ width: '100%'
171
+ },
172
+ style: {
173
+ // ECharts rounds the height to the nearest integer by default.
174
+ // This can cause unneccessary scrollbars when the total height of this chart exceeds the 'height' prop.
175
+ height: Math.floor(height - seriesNameHeight - valueFontHeight)
172
176
  },
173
177
  option: option,
174
178
  theme: chartsTheme.echartsTheme,
@@ -35,7 +35,7 @@ const DEFAULT_GET_ROW_ID = (data, index)=>{
35
35
  // does not do deep equality checking for objects and arrays.
36
36
  const DEFAULT_ROW_SELECTION = {};
37
37
  const DEFAULT_SORTING = [];
38
- function Table({ data, columns, cellConfigs, density = 'standard', defaultColumnWidth = _tablemodel.DEFAULT_COLUMN_WIDTH, defaultColumnHeight = 'auto', checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId = DEFAULT_GET_ROW_ID, rowSelection = DEFAULT_ROW_SELECTION, sorting = DEFAULT_SORTING, rowSelectionVariant = 'standard', ...otherProps }) {
38
+ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumnWidth = _tablemodel.DEFAULT_COLUMN_WIDTH, defaultColumnHeight = 'auto', checkboxSelection, onRowSelectionChange, onSortingChange, getCheckboxColor, getRowId = DEFAULT_GET_ROW_ID, rowSelection = DEFAULT_ROW_SELECTION, sorting = DEFAULT_SORTING, pagination, onPaginationChange, rowSelectionVariant = 'standard', ...otherProps }) {
39
39
  const theme = (0, _material.useTheme)();
40
40
  const handleRowSelectionChange = (rowSelectionUpdater)=>{
41
41
  const newRowSelection = typeof rowSelectionUpdater === 'function' ? rowSelectionUpdater(rowSelection) : rowSelectionUpdater;
@@ -122,6 +122,10 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
122
122
  getRowId,
123
123
  getCoreRowModel: (0, _reacttable.getCoreRowModel)(),
124
124
  getSortedRowModel: (0, _reacttable.getSortedRowModel)(),
125
+ getPaginationRowModel: pagination ? (0, _reacttable.getPaginationRowModel)() : undefined,
126
+ // without this setting, the getPaginationRowModel setting persists and it is not possible to switch from paginated to unpaginated
127
+ // can be removed once https://github.com/TanStack/table/pull/5974 is merged
128
+ manualPagination: !pagination,
125
129
  enableRowSelection: !!checkboxSelection,
126
130
  onRowSelectionChange: handleRowSelectionChange,
127
131
  onSortingChange: handleSortingChange,
@@ -130,7 +134,10 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
130
134
  sortDescFirst: true,
131
135
  state: {
132
136
  rowSelection,
133
- sorting
137
+ sorting,
138
+ ...pagination ? {
139
+ pagination
140
+ } : {}
134
141
  }
135
142
  });
136
143
  const handleRowClick = (0, _react.useCallback)((e, rowId)=>{
@@ -150,6 +157,9 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
150
157
  rows: table.getRowModel().rows,
151
158
  columns: table.getAllFlatColumns(),
152
159
  headers: table.getHeaderGroups(),
153
- cellConfigs: cellConfigs
160
+ cellConfigs: cellConfigs,
161
+ pagination: pagination,
162
+ onPaginationChange: onPaginationChange,
163
+ rowCount: table.getRowCount()
154
164
  });
155
165
  }
@@ -0,0 +1,31 @@
1
+ // Copyright 2025 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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ Object.defineProperty(exports, "TableFoot", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return TableFoot;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _react = require("react");
26
+ const TableFoot = /*#__PURE__*/ (0, _react.forwardRef)(function TableFoot(props, ref) {
27
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableFooter, {
28
+ ...props,
29
+ ref: ref
30
+ });
31
+ });
@@ -33,7 +33,8 @@ const _TableHeaderCell = require("./TableHeaderCell");
33
33
  const _TableCell = require("./TableCell");
34
34
  const _VirtualizedTableContainer = require("./VirtualizedTableContainer");
35
35
  const _useVirtualizedTableKeyboardNav = require("./hooks/useVirtualizedTableKeyboardNav");
36
- function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, cellConfigs }) {
36
+ const _TableFoot = require("./TableFoot");
37
+ function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultColumnHeight, onRowClick, onRowMouseOver, onRowMouseOut, rows, columns, headers, cellConfigs, pagination, onPaginationChange, rowCount }) {
37
38
  const virtuosoRef = (0, _react.useRef)(null);
38
39
  // Use a ref for these values because they are only needed for keyboard
39
40
  // focus interactions and setting them on state will lead to a significant
@@ -70,6 +71,7 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultC
70
71
  });
71
72
  },
72
73
  TableHead: _TableHead.TableHead,
74
+ TableFoot: _TableFoot.TableFoot,
73
75
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
74
76
  TableRow: ({ item, ...props })=>{
75
77
  const index = props['data-index'];
@@ -104,6 +106,20 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultC
104
106
  rows,
105
107
  width
106
108
  ]);
109
+ const handleChangePage = (_event, newPage)=>{
110
+ if (!pagination || !onPaginationChange) return;
111
+ onPaginationChange({
112
+ ...pagination,
113
+ pageIndex: newPage
114
+ });
115
+ };
116
+ const handleChangeRowsPerPage = (event)=>{
117
+ if (!pagination || !onPaginationChange) return;
118
+ onPaginationChange({
119
+ pageIndex: 0,
120
+ pageSize: parseInt(event.target.value, 10)
121
+ });
122
+ };
107
123
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
108
124
  style: {
109
125
  width,
@@ -151,6 +167,19 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, defaultC
151
167
  })
152
168
  });
153
169
  },
170
+ fixedFooterContent: pagination ? ()=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TableRow, {
171
+ sx: {
172
+ backgroundColor: (theme)=>theme.palette.background.default
173
+ },
174
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.TablePagination, {
175
+ colSpan: columns.length,
176
+ count: rowCount,
177
+ page: pagination.pageIndex,
178
+ rowsPerPage: pagination.pageSize,
179
+ onPageChange: handleChangePage,
180
+ onRowsPerPageChange: handleChangeRowsPerPage
181
+ })
182
+ }) : undefined,
154
183
  itemContent: (index)=>{
155
184
  const row = rows[index];
156
185
  if (!row) {
@@ -44,7 +44,6 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
44
44
  // Ensure user is hovering over a chart before checking for nearby series.
45
45
  if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
46
46
  const chart = chartRef.current;
47
- const chartWidth = chart?.getWidth() ?? _tooltipmodel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
48
47
  // Get series nearby the cursor and pass into tooltip content children.
49
48
  const nearbySeries = (0, _nearbyseries.legacyGetNearbySeriesData)({
50
49
  mousePos,
@@ -61,9 +60,7 @@ const LineChartTooltip = /*#__PURE__*/ (0, _react.memo)(function LineChartToolti
61
60
  const containerElement = containerId ? document.querySelector(containerId) : undefined;
62
61
  // if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off
63
62
  const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
64
- if (!isTooltipPinned) {
65
- transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);
66
- }
63
+ transform.current = (0, _utils.assembleTransform)(mousePos, pinnedPos, height ?? 0, width ?? 0, containerElement);
67
64
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Portal, {
68
65
  container: containerElement,
69
66
  children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
@@ -44,13 +44,10 @@ const TimeChartTooltip = /*#__PURE__*/ (0, _react.memo)(function TimeChartToolti
44
44
  // Ensure user is hovering over a chart before checking for nearby series.
45
45
  if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
46
46
  const chart = chartRef.current;
47
- const chartWidth = chart?.getWidth() ?? _tooltipmodel.FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
48
47
  const containerElement = containerId ? document.querySelector(containerId) : undefined;
49
48
  // if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off
50
49
  const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
51
- if (!isTooltipPinned) {
52
- transform.current = (0, _utils.assembleTransform)(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);
53
- }
50
+ transform.current = (0, _utils.assembleTransform)(mousePos, pinnedPos, height ?? 0, width ?? 0, containerElement);
54
51
  // Get series nearby the cursor and pass into tooltip content children.
55
52
  const nearbySeries = (0, _nearbyseries.getNearbySeriesData)({
56
53
  mousePos,
@@ -66,18 +66,9 @@ _export(exports, {
66
66
  UNPIN_TOOLTIP_HELP_TEXT: function() {
67
67
  return UNPIN_TOOLTIP_HELP_TEXT;
68
68
  },
69
- browser: function() {
70
- return browser;
71
- },
72
69
  defaultCursorData: function() {
73
70
  return defaultCursorData;
74
71
  },
75
- pointerEventsSupported: function() {
76
- return pointerEventsSupported;
77
- },
78
- trackingEventName: function() {
79
- return trackingEventName;
80
- },
81
72
  useMousePosition: function() {
82
73
  return useMousePosition;
83
74
  }
@@ -117,14 +108,6 @@ const defaultCursorData = {
117
108
  chartWidth: 0
118
109
  };
119
110
  const EMPTY_TOOLTIP_DATA = [];
120
- const browser = {
121
- // IE 11 Trident/7.0; rv:11.0
122
- ie: navigator.userAgent.match(/MSIE\s([\d.]+)/) || navigator.userAgent.match(/Trident\/.+?rv:(([\d.]+))/),
123
- // IE 12 and 12+
124
- edge: navigator.userAgent.match(/Edge?\/([\d.]+)/)
125
- };
126
- const pointerEventsSupported = 'onpointerdown' in window && (browser.edge || browser.ie && browser.ie[1] && +browser.ie[1] >= 11);
127
- const trackingEventName = pointerEventsSupported ? 'pointermove' : 'mousemove';
128
111
  const useMousePosition = ()=>{
129
112
  const [coords, setCoords] = (0, _react.useState)(null);
130
113
  (0, _react.useEffect)(()=>{
@@ -139,22 +122,20 @@ const useMousePosition = ()=>{
139
122
  y: e.clientY
140
123
  },
141
124
  plotCanvas: {
142
- // Always use zrender mousemove coords since they handle browser inconsistencies for us
125
+ // Default to zrender mousemove coords since they handle browser inconsistencies for us
143
126
  // ex: Firefox and Chrome have slightly different implementations of offsetX and offsetY
144
127
  // more info: https://github.com/ecomfe/zrender/blob/5.5.0/src/core/event.ts#L46-L120
145
- x: e.zrX,
146
- y: e.zrY
128
+ // Fallback to offsetX and offsetY to ensure tooltip works correctly in Edge
129
+ x: e.zrX ?? e.offsetX,
130
+ y: e.zrY ?? e.offsetY
147
131
  },
148
132
  // necessary to check whether cursor target matches correct chart canvas (since each chart has its own mousemove listener)
149
133
  target: e.target
150
134
  });
151
135
  };
152
- // Devices that both enabled touch and mouse don't trigger touch events correctly
153
- // which leads to missing zrender mousemove coordinates
154
- // {@link https://github.com/ecomfe/zrender/blob/ae8cfaae186e6c1bf66b5dc431b2cdda5e67dacf/src/dom/HandlerProxy.ts#L423-L428 }
155
- window.addEventListener(trackingEventName, setFromEvent);
136
+ window.addEventListener('mousemove', setFromEvent);
156
137
  return ()=>{
157
- window.removeEventListener(trackingEventName, setFromEvent);
138
+ window.removeEventListener('mousemove', setFromEvent);
158
139
  };
159
140
  }, []);
160
141
  return coords;
@@ -29,7 +29,7 @@ _export(exports, {
29
29
  }
30
30
  });
31
31
  const _tooltipmodel = require("./tooltip-model");
32
- function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, tooltipWidth, containerElement) {
32
+ function assembleTransform(mousePos, pinnedPos, tooltipHeight, tooltipWidth, containerElement) {
33
33
  if (mousePos === null) {
34
34
  return undefined;
35
35
  }
@@ -39,33 +39,37 @@ function assembleTransform(mousePos, chartWidth, pinnedPos, tooltipHeight, toolt
39
39
  mousePos = pinnedPos;
40
40
  }
41
41
  if (mousePos.plotCanvas.x === undefined) return undefined;
42
- // By default, tooltip is located in a Portal attached to the body.
43
- // Using page coordinates instead of viewport ensures the tooltip is
44
- // absolutely positioned correctly as the user scrolls
45
- let x = mousePos.page.x;
42
+ let x = mousePos.page.x + cursorPaddingX; // Default to right side of the cursor
46
43
  let y = mousePos.page.y + cursorPaddingY;
47
- // If containerElement is defined, tooltip is attached to the containerElement instead.
48
- let containerRect;
44
+ // If containerElement is defined, adjust coordinates relative to the container
49
45
  if (containerElement) {
50
- // get the container's position relative to viewport
51
- containerRect = containerElement.getBoundingClientRect();
52
- // calculate the mouse position relative to container
46
+ const containerRect = containerElement.getBoundingClientRect();
53
47
  x = x - containerRect.left + containerElement.scrollLeft;
54
48
  y = y - containerRect.top + containerElement.scrollTop;
55
- }
56
- if (mousePos.client.y + tooltipHeight + cursorPaddingY > window.innerHeight) {
57
- // adjust so tooltip does not get cut off at bottom of chart
58
- // multiplier ensures tooltip isn't overly adjusted and gets cut off at the top of the viewport
59
- y = y - tooltipHeight * _tooltipmodel.TOOLTIP_ADJUST_Y_POS_MULTIPLIER;
60
- // If y is now above of the top of containerElement, set y close to 0 so tooltip does not get cut off
61
- if (containerRect && y < containerRect.top) {
62
- y = _tooltipmodel.TOOLTIP_PADDING / 2; // leaves room for some padding around tooltip
49
+ // Ensure tooltip does not go out of the container's bottom
50
+ const containerBottom = containerRect.top + containerElement.scrollHeight;
51
+ if (y + tooltipHeight > containerBottom) {
52
+ y = Math.max(containerBottom - tooltipHeight - cursorPaddingY, _tooltipmodel.TOOLTIP_PADDING / 2);
53
+ }
54
+ } else {
55
+ // Ensure tooltip does not go out of the screen on the bottom
56
+ if (y + tooltipHeight > window.innerHeight + window.scrollY) {
57
+ y = Math.max(window.innerHeight + window.scrollY - tooltipHeight - cursorPaddingY, _tooltipmodel.TOOLTIP_PADDING / 2);
63
58
  }
64
59
  }
65
- // use tooltip width to determine when to repos from right to left
66
- const xPosAdjustThreshold = chartWidth - tooltipWidth * 0.9;
67
- // reposition so tooltip is never too close to right side of chart or left side of browser window
68
- return mousePos.plotCanvas.x > xPosAdjustThreshold && x > _tooltipmodel.TOOLTIP_MAX_WIDTH ? `translate3d(${x - cursorPaddingX}px, ${y}px, 0) translateX(-100%)` : `translate3d(${x + cursorPaddingX}px, ${y}px, 0)`;
60
+ // Ensure tooltip does not go out of the screen on the right
61
+ if (x + tooltipWidth > window.innerWidth) {
62
+ x = mousePos.page.x - tooltipWidth - cursorPaddingX; // Move to the left of the cursor
63
+ }
64
+ // Ensure tooltip does not go out of the screen on the left
65
+ if (x < cursorPaddingX) {
66
+ x = cursorPaddingX;
67
+ }
68
+ // Ensure tooltip does not go out of the screen on the top
69
+ if (y < _tooltipmodel.TOOLTIP_PADDING / 2) {
70
+ y = _tooltipmodel.TOOLTIP_PADDING / 2;
71
+ }
72
+ return `translate3d(${x}px, ${y}px, 0)`;
69
73
  }
70
74
  function getTooltipStyles(theme, pinnedPos, maxHeight) {
71
75
  const adjustedMaxHeight = maxHeight ? maxHeight - _tooltipmodel.TOOLTIP_PADDING : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/components",
3
- "version": "0.51.0-beta.1",
3
+ "version": "0.51.0-rc.0",
4
4
  "description": "Common UI components used across Perses features",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -38,7 +38,7 @@
38
38
  "@codemirror/lang-json": "^6.0.1",
39
39
  "@fontsource/lato": "^4.5.10",
40
40
  "@mui/x-date-pickers": "^7.23.1",
41
- "@perses-dev/core": "0.51.0-beta.1",
41
+ "@perses-dev/core": "0.51.0-rc.0",
42
42
  "@tanstack/react-table": "^8.20.5",
43
43
  "@uiw/react-codemirror": "^4.19.1",
44
44
  "date-fns": "^4.1.0",