@perses-dev/components 0.51.0-beta.0 → 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 (92) hide show
  1. package/dist/BarChart/BarChart.js.map +1 -1
  2. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  3. package/dist/ColorPicker/OptionsColorPicker.js.map +1 -1
  4. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  5. package/dist/DragAndDrop/DropIndicator.js.map +1 -1
  6. package/dist/Drawer/Drawer.js.map +1 -1
  7. package/dist/EChart/EChart.d.ts +3 -2
  8. package/dist/EChart/EChart.d.ts.map +1 -1
  9. package/dist/EChart/EChart.js +22 -4
  10. package/dist/EChart/EChart.js.map +1 -1
  11. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  12. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  13. package/dist/JSONEditor.d.ts.map +1 -1
  14. package/dist/JSONEditor.js +5 -6
  15. package/dist/JSONEditor.js.map +1 -1
  16. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  17. package/dist/Overlay/Overlay.js.map +1 -1
  18. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  19. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  20. package/dist/StatChart/StatChart.d.ts.map +1 -1
  21. package/dist/StatChart/StatChart.js +6 -2
  22. package/dist/StatChart/StatChart.js.map +1 -1
  23. package/dist/StatChart/calculateFontSize.js.map +1 -1
  24. package/dist/StatusHistoryChart/utils/get-color.js.map +1 -1
  25. package/dist/Table/Table.d.ts +1 -1
  26. package/dist/Table/Table.d.ts.map +1 -1
  27. package/dist/Table/Table.js +15 -4
  28. package/dist/Table/Table.js.map +1 -1
  29. package/dist/Table/TableCell.d.ts +2 -1
  30. package/dist/Table/TableCell.d.ts.map +1 -1
  31. package/dist/Table/TableCell.js +4 -2
  32. package/dist/Table/TableCell.js.map +1 -1
  33. package/dist/Table/TableFoot.d.ts +4 -0
  34. package/dist/Table/TableFoot.d.ts.map +1 -0
  35. package/dist/Table/TableFoot.js +23 -0
  36. package/dist/Table/TableFoot.js.map +1 -0
  37. package/dist/Table/TableHeaderCell.js.map +1 -1
  38. package/dist/Table/VirtualizedTable.d.ts +3 -2
  39. package/dist/Table/VirtualizedTable.d.ts.map +1 -1
  40. package/dist/Table/VirtualizedTable.js +33 -2
  41. package/dist/Table/VirtualizedTable.js.map +1 -1
  42. package/dist/Table/model/table-model.d.ts +18 -2
  43. package/dist/Table/model/table-model.d.ts.map +1 -1
  44. package/dist/Table/model/table-model.js +4 -2
  45. package/dist/Table/model/table-model.js.map +1 -1
  46. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  47. package/dist/ThresholdsEditor/ThresholdsEditor.js +1 -1
  48. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  49. package/dist/TimeChart/TimeChart.js +4 -4
  50. package/dist/TimeChart/TimeChart.js.map +1 -1
  51. package/dist/TimeRangeSelector/DateTimeRangePicker.js +1 -1
  52. package/dist/TimeRangeSelector/DateTimeRangePicker.js.map +1 -1
  53. package/dist/TimeRangeSelector/TimeRangeSelector.d.ts +1 -1
  54. package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -1
  55. package/dist/TimeRangeSelector/utils.js.map +1 -1
  56. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  57. package/dist/TimeSeriesTooltip/LineChartTooltip.js +2 -5
  58. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  59. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  60. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  61. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  62. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +2 -5
  63. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  64. package/dist/TimeSeriesTooltip/tooltip-model.d.ts +1 -8
  65. package/dist/TimeSeriesTooltip/tooltip-model.d.ts.map +1 -1
  66. package/dist/TimeSeriesTooltip/tooltip-model.js +6 -16
  67. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  68. package/dist/TimeSeriesTooltip/utils.d.ts +1 -1
  69. package/dist/TimeSeriesTooltip/utils.d.ts.map +1 -1
  70. package/dist/TimeSeriesTooltip/utils.js +27 -23
  71. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  72. package/dist/TransformsEditor/TransformEditorContainer.js.map +1 -1
  73. package/dist/cjs/EChart/EChart.js +21 -3
  74. package/dist/cjs/JSONEditor.js +4 -5
  75. package/dist/cjs/StatChart/StatChart.js +6 -2
  76. package/dist/cjs/Table/Table.js +14 -3
  77. package/dist/cjs/Table/TableCell.js +4 -2
  78. package/dist/cjs/Table/TableFoot.js +31 -0
  79. package/dist/cjs/Table/VirtualizedTable.js +32 -1
  80. package/dist/cjs/Table/model/table-model.js +7 -2
  81. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +9 -9
  82. package/dist/cjs/TimeChart/TimeChart.js +3 -3
  83. package/dist/cjs/TimeRangeSelector/DateTimeRangePicker.js +2 -2
  84. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +1 -4
  85. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +1 -4
  86. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +6 -25
  87. package/dist/cjs/TimeSeriesTooltip/utils.js +26 -22
  88. package/dist/context/SnackbarProvider.js.map +1 -1
  89. package/dist/model/timeOption.js.map +1 -1
  90. package/dist/theme/component-overrides/alert.js.map +1 -1
  91. package/dist/utils/component-ids.js.map +1 -1
  92. package/package.json +5 -8
@@ -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;AAC7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W,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"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TransformsEditor/TransformEditorContainer.tsx"],"sourcesContent":["// Copyright 2024 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 { Divider, IconButton, Stack, Tooltip, Typography } from '@mui/material';\nimport ChevronRight from 'mdi-material-ui/ChevronRight';\nimport ChevronDown from 'mdi-material-ui/ChevronDown';\nimport EyeOffIcon from 'mdi-material-ui/EyeOffOutline';\nimport EyeIcon from 'mdi-material-ui/EyeOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { Transform, TRANSFORM_TEXT } from '@perses-dev/core';\nimport { ReactElement } from 'react';\nimport { TransformEditor, TransformEditorProps } from './TransformEditor';\n\nexport interface TransformEditorContainerProps extends TransformEditorProps {\n index?: number;\n isCollapsed: boolean;\n onCollapse: (collapsed: boolean) => void;\n onDelete: () => void;\n}\n\nexport function TransformEditorContainer({\n index,\n value,\n isCollapsed,\n onChange,\n onCollapse,\n onDelete,\n ...props\n}: TransformEditorContainerProps): ReactElement {\n function handleTransformDisable(): void {\n onChange({ ...value, spec: { ...value.spec, disabled: !value.spec?.disabled } } as Transform);\n }\n\n return (\n <Stack {...props}>\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n borderBottom={1}\n borderColor={(theme) => theme.palette.divider}\n justifyContent=\"space-between\"\n gap={4}\n >\n <Stack direction=\"row\" gap={1}>\n <IconButton data-testid={`transform-toggle#${index}`} size=\"small\" onClick={() => onCollapse(!isCollapsed)}>\n {isCollapsed ? <ChevronRight /> : <ChevronDown />}\n </IconButton>\n <Typography variant=\"overline\" component=\"h4\" sx={{ textTransform: 'none' }}>\n {value.kind ? (\n <span>\n <strong>{TRANSFORM_TEXT[value.kind]}</strong>\n </span>\n ) : (\n <strong>Select a transformation kind</strong>\n )}\n </Typography>\n </Stack>\n\n <Stack direction=\"row\" gap={1}>\n {isCollapsed && (\n <>\n <Tooltip\n title={value.spec?.disabled ? 'Enable transformation' : 'Disable transformation'}\n placement=\"top\"\n >\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={handleTransformDisable}>\n {value.spec?.disabled ? <EyeOffIcon /> : <EyeIcon />}\n </IconButton>\n </Tooltip>\n <Divider flexItem orientation=\"vertical\" variant=\"middle\" />\n </>\n )}\n <Tooltip title=\"Remove transformation\" placement=\"top\">\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n </Stack>\n </Stack>\n {!isCollapsed && <TransformEditor value={value} onChange={onChange} />}\n </Stack>\n );\n}\n"],"names":["Divider","IconButton","Stack","Tooltip","Typography","ChevronRight","ChevronDown","EyeOffIcon","EyeIcon","DeleteIcon","TRANSFORM_TEXT","TransformEditor","TransformEditorContainer","index","value","isCollapsed","onChange","onCollapse","onDelete","props","handleTransformDisable","spec","disabled","direction","alignItems","borderBottom","borderColor","theme","palette","divider","justifyContent","gap","data-testid","size","onClick","variant","component","sx","textTransform","kind","span","strong","title","placement","marginLeft","flexItem","orientation"],"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,SAASA,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,QAAQ,gBAAgB;AAChF,OAAOC,kBAAkB,+BAA+B;AACxD,OAAOC,iBAAiB,8BAA8B;AACtD,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,aAAa,6BAA6B;AACjD,OAAOC,gBAAgB,gCAAgC;AACvD,SAAoBC,cAAc,QAAQ,mBAAmB;AAE7D,SAASC,eAAe,QAA8B,oBAAoB;AAS1E,OAAO,SAASC,yBAAyB,EACvCC,KAAK,EACLC,KAAK,EACLC,WAAW,EACXC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACR,GAAGC,OAC2B;IAC9B,SAASC;QACPJ,SAAS;YAAE,GAAGF,KAAK;YAAEO,MAAM;gBAAE,GAAGP,MAAMO,IAAI;gBAAEC,UAAU,CAACR,MAAMO,IAAI,EAAE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or/TransformEditorContainer.tsx"],"sourcesContent":["// Copyright 2024 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 { Divider, IconButton, Stack, Tooltip, Typography } from '@mui/material';\nimport ChevronRight from 'mdi-material-ui/ChevronRight';\nimport ChevronDown from 'mdi-material-ui/ChevronDown';\nimport EyeOffIcon from 'mdi-material-ui/EyeOffOutline';\nimport EyeIcon from 'mdi-material-ui/EyeOutline';\nimport DeleteIcon from 'mdi-material-ui/DeleteOutline';\nimport { Transform, TRANSFORM_TEXT } from '@perses-dev/core';\nimport { ReactElement } from 'react';\nimport { TransformEditor, TransformEditorProps } from './TransformEditor';\n\nexport interface TransformEditorContainerProps extends TransformEditorProps {\n index?: number;\n isCollapsed: boolean;\n onCollapse: (collapsed: boolean) => void;\n onDelete: () => void;\n}\n\nexport function TransformEditorContainer({\n index,\n value,\n isCollapsed,\n onChange,\n onCollapse,\n onDelete,\n ...props\n}: TransformEditorContainerProps): ReactElement {\n function handleTransformDisable(): void {\n onChange({ ...value, spec: { ...value.spec, disabled: !value.spec?.disabled } } as Transform);\n }\n\n return (\n <Stack {...props}>\n <Stack\n direction=\"row\"\n alignItems=\"center\"\n borderBottom={1}\n borderColor={(theme) => theme.palette.divider}\n justifyContent=\"space-between\"\n gap={4}\n >\n <Stack direction=\"row\" gap={1}>\n <IconButton data-testid={`transform-toggle#${index}`} size=\"small\" onClick={() => onCollapse(!isCollapsed)}>\n {isCollapsed ? <ChevronRight /> : <ChevronDown />}\n </IconButton>\n <Typography variant=\"overline\" component=\"h4\" sx={{ textTransform: 'none' }}>\n {value.kind ? (\n <span>\n <strong>{TRANSFORM_TEXT[value.kind]}</strong>\n </span>\n ) : (\n <strong>Select a transformation kind</strong>\n )}\n </Typography>\n </Stack>\n\n <Stack direction=\"row\" gap={1}>\n {isCollapsed && (\n <>\n <Tooltip\n title={value.spec?.disabled ? 'Enable transformation' : 'Disable transformation'}\n placement=\"top\"\n >\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={handleTransformDisable}>\n {value.spec?.disabled ? <EyeOffIcon /> : <EyeIcon />}\n </IconButton>\n </Tooltip>\n <Divider flexItem orientation=\"vertical\" variant=\"middle\" />\n </>\n )}\n <Tooltip title=\"Remove transformation\" placement=\"top\">\n <IconButton size=\"small\" sx={{ marginLeft: 'auto' }} onClick={onDelete}>\n <DeleteIcon />\n </IconButton>\n </Tooltip>\n </Stack>\n </Stack>\n {!isCollapsed && <TransformEditor value={value} onChange={onChange} />}\n </Stack>\n );\n}\n"],"names":["Divider","IconButton","Stack","Tooltip","Typography","ChevronRight","ChevronDown","EyeOffIcon","EyeIcon","DeleteIcon","TRANSFORM_TEXT","TransformEditor","TransformEditorContainer","index","value","isCollapsed","onChange","onCollapse","onDelete","props","handleTransformDisable","spec","disabled","direction","alignItems","borderBottom","borderColor","theme","palette","divider","justifyContent","gap","data-testid","size","onClick","variant","component","sx","textTransform","kind","span","strong","title","placement","marginLeft","flexItem","orientation"],"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,SAASA,OAAO,EAAEC,UAAU,EAAEC,KAAK,EAAEC,OAAO,EAAEC,UAAU,QAAQ,gBAAgB;AAChF,OAAOC,kBAAkB,+BAA+B;AACxD,OAAOC,iBAAiB,8BAA8B;AACtD,OAAOC,gBAAgB,gCAAgC;AACvD,OAAOC,aAAa,6BAA6B;AACjD,OAAOC,gBAAgB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AACR;wCAAQ6C,QAAQ;wCAACC,aAAY;wCAAWX,SAAQ;;;;0CAGrD,KAAChC;gCAAQuC,OAAM;gCAAwBC,WAAU;0CAC/C,cAAA,KAAC1C;oCAAWgC,MAAK;oCAAQI,IAAI;wCAAEO,YAAY;oCAAO;oCAAGV,SAAShB;8CAC5D,cAAA,KAACT;;;;;;;YAKR,CAACM,6BAAe,KAACJ;gBAAgBG,OAAOA;gBAAOE,UAAUA;;;;AAGhE"}
@@ -26,11 +26,27 @@ const _core = require("echarts/core");
26
26
  const _material = require("@mui/material");
27
27
  const _isEqual = /*#__PURE__*/ _interop_require_default(require("lodash/isEqual"));
28
28
  const _debounce = /*#__PURE__*/ _interop_require_default(require("lodash/debounce"));
29
+ const _charts = require("echarts/charts");
30
+ const _components = require("echarts/components");
31
+ const _renderers = require("echarts/renderers");
29
32
  function _interop_require_default(obj) {
30
33
  return obj && obj.__esModule ? obj : {
31
34
  default: obj
32
35
  };
33
36
  }
37
+ // Loading the ECharts extensions should happen in the respective plugin (in this case, the scatterplot + custom plugin).
38
+ // This is a workaround for https://github.com/perses/plugins/issues/83.
39
+ (0, _core.use)([
40
+ _components.DatasetComponent,
41
+ _components.DataZoomComponent,
42
+ _components.LegendComponent,
43
+ _charts.ScatterChart,
44
+ _charts.CustomChart,
45
+ _components.GridComponent,
46
+ _components.TitleComponent,
47
+ _components.TooltipComponent,
48
+ _renderers.CanvasRenderer
49
+ ]);
34
50
  const mouseEvents = [
35
51
  'click',
36
52
  'dblclick',
@@ -47,7 +63,7 @@ const batchEvents = [
47
63
  'downplay',
48
64
  'highlight'
49
65
  ];
50
- 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 }) {
51
67
  const initialOption = (0, _react.useRef)(option);
52
68
  const prevOption = (0, _react.useRef)(option);
53
69
  const containerRef = (0, _react.useRef)(null);
@@ -137,11 +153,13 @@ const EChart = /*#__PURE__*/ (0, _react.memo)(function EChart({ option, theme, r
137
153
  });
138
154
  updateSize();
139
155
  }, [
140
- sx
156
+ sx,
157
+ style
141
158
  ]);
142
159
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
143
160
  ref: containerRef,
144
- sx: sx
161
+ sx: sx,
162
+ style: style
145
163
  });
146
164
  });
147
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, 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)=>{
@@ -145,10 +152,14 @@ function Table({ data, columns, cellConfigs, density = 'standard', defaultColumn
145
152
  ...otherProps,
146
153
  density: density,
147
154
  defaultColumnWidth: defaultColumnWidth,
155
+ defaultColumnHeight: defaultColumnHeight,
148
156
  onRowClick: handleRowClick,
149
157
  rows: table.getRowModel().rows,
150
158
  columns: table.getAllFlatColumns(),
151
159
  headers: table.getHeaderGroups(),
152
- cellConfigs: cellConfigs
160
+ cellConfigs: cellConfigs,
161
+ pagination: pagination,
162
+ onPaginationChange: onPaginationChange,
163
+ rowCount: table.getRowCount()
153
164
  });
154
165
  }
@@ -39,7 +39,7 @@ const StyledMuiTableCell = (0, _material.styled)(_material.TableCell)(({ theme }
39
39
  borderRadius: 0
40
40
  }
41
41
  }));
42
- function TableCell({ children, density, variant, width, focusState = 'none', onFocusTrigger, isFirstColumn, isLastColumn, description, align, color, backgroundColor, ...otherProps }) {
42
+ function TableCell({ children, density, variant, width, defaultColumnHeight, focusState = 'none', onFocusTrigger, isFirstColumn, isLastColumn, description, align, color, backgroundColor, ...otherProps }) {
43
43
  const theme = (0, _material.useTheme)();
44
44
  const elRef = (0, _react.useRef)();
45
45
  const isHeader = variant === 'head';
@@ -102,8 +102,10 @@ function TableCell({ children, density, variant, width, focusState = 'none', onF
102
102
  id: "original-cell",
103
103
  sx: {
104
104
  ...(0, _tablemodel.getTableCellLayout)(theme, density, {
105
+ isHeader,
105
106
  isLastColumn,
106
- isFirstColumn
107
+ isFirstColumn,
108
+ defaultColumnHeight
107
109
  }),
108
110
  position: 'relative',
109
111
  // Text truncation. Currently enforced on all cells. We may control
@@ -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, 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, onRowCli
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, onRowCli
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,
@@ -135,6 +151,7 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
135
151
  sortDirection: typeof isSorted === 'string' ? isSorted : undefined,
136
152
  nextSortDirection: typeof nextSorting === 'string' ? nextSorting : undefined,
137
153
  width: column.getSize() || defaultColumnWidth,
154
+ defaultColumnHeight: defaultColumnHeight,
138
155
  align: column.columnDef.meta?.align,
139
156
  variant: "head",
140
157
  density: density,
@@ -150,6 +167,19 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
150
167
  })
151
168
  });
152
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,
153
183
  itemContent: (index)=>{
154
184
  const row = rows[index];
155
185
  if (!row) {
@@ -182,6 +212,7 @@ function VirtualizedTable({ width, height, density, defaultColumnWidth, onRowCli
182
212
  "data-testid": cell.id,
183
213
  title: description || cellConfig?.text || cellContent,
184
214
  width: cell.column.getSize() || defaultColumnWidth,
215
+ defaultColumnHeight: defaultColumnHeight,
185
216
  align: cell.column.columnDef.meta?.align,
186
217
  density: density,
187
218
  focusState: getFocusState(position),
@@ -21,6 +21,9 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
+ DEFAULT_COLUMN_HEIGHT: function() {
25
+ return DEFAULT_COLUMN_HEIGHT;
26
+ },
24
27
  DEFAULT_COLUMN_WIDTH: function() {
25
28
  return DEFAULT_COLUMN_WIDTH;
26
29
  },
@@ -32,6 +35,7 @@ _export(exports, {
32
35
  }
33
36
  });
34
37
  const DEFAULT_COLUMN_WIDTH = 150;
38
+ const DEFAULT_COLUMN_HEIGHT = 40;
35
39
  function calculateTableCellHeight(lineHeight, paddingY) {
36
40
  // Doing a bunch of math to enforce height to avoid weirdness with mismatched
37
41
  // heights based on customization of cell contents.
@@ -39,7 +43,7 @@ function calculateTableCellHeight(lineHeight, paddingY) {
39
43
  const verticalPaddingNum = typeof paddingY === 'string' ? parseInt(paddingY, 10) : paddingY;
40
44
  return lineHeightNum + verticalPaddingNum * 2;
41
45
  }
42
- function getTableCellLayout(theme, density, { isLastColumn, isFirstColumn } = {}) {
46
+ function getTableCellLayout(theme, density, { isHeader, isLastColumn, isFirstColumn, defaultColumnHeight } = {}) {
43
47
  // Density Standard
44
48
  let paddingY = theme.spacing(1);
45
49
  let basePaddingX = theme.spacing(1.25);
@@ -66,9 +70,10 @@ function getTableCellLayout(theme, density, { isLastColumn, isFirstColumn } = {}
66
70
  lineHeight = theme.typography.body1.lineHeight;
67
71
  fontSize = theme.typography.body1.fontSize;
68
72
  }
73
+ const height = isHeader || !defaultColumnHeight || defaultColumnHeight === 'auto' ? calculateTableCellHeight(lineHeight, paddingY) : defaultColumnHeight;
69
74
  return {
70
75
  padding: `${paddingY} ${paddingRight} ${paddingY} ${paddingLeft}`,
71
- height: calculateTableCellHeight(lineHeight, paddingY),
76
+ height: height,
72
77
  fontSize: fontSize,
73
78
  lineHeight: lineHeight
74
79
  };
@@ -22,7 +22,7 @@ Object.defineProperty(exports, "ThresholdsEditor", {
22
22
  });
23
23
  const _jsxruntime = require("react/jsx-runtime");
24
24
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
25
- const _immer = /*#__PURE__*/ _interop_require_default(require("immer"));
25
+ const _immer = require("immer");
26
26
  const _material = require("@mui/material");
27
27
  const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
28
28
  const _system = require("@mui/system");
@@ -99,7 +99,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
99
99
  steps?.length
100
100
  ]);
101
101
  const handleThresholdValueChange = (e, i)=>{
102
- setSteps((0, _immer.default)(steps, (draft)=>{
102
+ setSteps((0, _immer.produce)(steps, (draft)=>{
103
103
  const step = draft?.[i];
104
104
  if (step) {
105
105
  step.value = Number(e.target.value);
@@ -108,7 +108,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
108
108
  };
109
109
  const handleThresholdColorChange = (color, i)=>{
110
110
  if (thresholds !== undefined) {
111
- onChange((0, _immer.default)(thresholds, (draft)=>{
111
+ onChange((0, _immer.produce)(thresholds, (draft)=>{
112
112
  if (draft.steps !== undefined) {
113
113
  const step = draft.steps[i];
114
114
  if (step) {
@@ -120,7 +120,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
120
120
  };
121
121
  const handleDefaultColorChange = (color)=>{
122
122
  if (thresholds !== undefined) {
123
- onChange((0, _immer.default)(thresholds, (draft)=>{
123
+ onChange((0, _immer.produce)(thresholds, (draft)=>{
124
124
  draft.defaultColor = color;
125
125
  }));
126
126
  } else {
@@ -137,7 +137,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
137
137
  ];
138
138
  sortedSteps.sort((a, b)=>a.value - b.value);
139
139
  if (thresholds !== undefined) {
140
- onChange((0, _immer.default)(thresholds, (draft)=>{
140
+ onChange((0, _immer.produce)(thresholds, (draft)=>{
141
141
  draft.steps = sortedSteps;
142
142
  }));
143
143
  }
@@ -145,7 +145,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
145
145
  };
146
146
  const deleteThreshold = (i)=>{
147
147
  if (thresholds !== undefined) {
148
- const updatedThresholds = (0, _immer.default)(thresholds, (draft)=>{
148
+ const updatedThresholds = (0, _immer.produce)(thresholds, (draft)=>{
149
149
  if (draft.steps) {
150
150
  draft.steps.splice(i, 1);
151
151
  }
@@ -164,7 +164,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
164
164
  ]
165
165
  });
166
166
  } else if (thresholds && thresholds.steps === undefined) {
167
- onChange((0, _immer.default)(thresholds, (draft)=>{
167
+ onChange((0, _immer.produce)(thresholds, (draft)=>{
168
168
  draft.steps = [
169
169
  {
170
170
  value: DEFAULT_STEP
@@ -172,7 +172,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
172
172
  ];
173
173
  }));
174
174
  } else {
175
- onChange((0, _immer.default)(thresholds, (draft)=>{
175
+ onChange((0, _immer.produce)(thresholds, (draft)=>{
176
176
  const steps = draft.steps;
177
177
  if (steps?.length) {
178
178
  const lastStep = steps[steps.length - 1];
@@ -192,7 +192,7 @@ function ThresholdsEditor({ thresholds, onChange, hideDefault, disablePercentMod
192
192
  const handleModeChange = (event, value)=>{
193
193
  const mode = value === 'percent' ? 'percent' : undefined;
194
194
  if (thresholds !== undefined) {
195
- onChange((0, _immer.default)(thresholds, (draft)=>{
195
+ onChange((0, _immer.produce)(thresholds, (draft)=>{
196
196
  draft.mode = mode;
197
197
  }));
198
198
  } else {
@@ -152,7 +152,7 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
152
152
  const values = d.values.map(([timestamp, value])=>{
153
153
  const val = value === null ? '-' : value; // echarts use '-' to represent null data
154
154
  return [
155
- isLocalTimeZone ? timestamp : (0, _datefnstz.utcToZonedTime)(timestamp, timeZone),
155
+ isLocalTimeZone ? timestamp : (0, _datefnstz.toZonedTime)(timestamp, timeZone),
156
156
  val
157
157
  ];
158
158
  });
@@ -176,8 +176,8 @@ const TimeChart = /*#__PURE__*/ (0, _react.forwardRef)(function TimeChart({ heig
176
176
  series: updatedSeriesMapping,
177
177
  xAxis: {
178
178
  type: 'time',
179
- min: isLocalTimeZone ? timeScale.startMs : (0, _datefnstz.utcToZonedTime)(timeScale.startMs, timeZone),
180
- max: isLocalTimeZone ? timeScale.endMs : (0, _datefnstz.utcToZonedTime)(timeScale.endMs, timeZone),
179
+ min: isLocalTimeZone ? timeScale.startMs : (0, _datefnstz.toZonedTime)(timeScale.startMs, timeZone),
180
+ max: isLocalTimeZone ? timeScale.endMs : (0, _datefnstz.toZonedTime)(timeScale.endMs, timeZone),
181
181
  axisLabel: {
182
182
  hideOverlap: true,
183
183
  formatter: (0, _utils.getFormattedAxisLabel)(timeScale.rangeMs ?? 0)
@@ -24,7 +24,7 @@ const _jsxruntime = require("react/jsx-runtime");
24
24
  const _react = require("react");
25
25
  const _material = require("@mui/material");
26
26
  const _xdatepickers = require("@mui/x-date-pickers");
27
- const _AdapterDateFns = require("@mui/x-date-pickers/AdapterDateFns");
27
+ const _AdapterDateFnsV3 = require("@mui/x-date-pickers/AdapterDateFnsV3");
28
28
  const _context = require("../context");
29
29
  const _ErrorBoundary = require("../ErrorBoundary");
30
30
  const _ErrorAlert = require("../ErrorAlert");
@@ -86,7 +86,7 @@ const DateTimeRangePicker = ({ initialTimeRange, onChange, onCancel })=>{
86
86
  }
87
87
  };
88
88
  return /*#__PURE__*/ (0, _jsxruntime.jsx)(_xdatepickers.LocalizationProvider, {
89
- dateAdapter: _AdapterDateFns.AdapterDateFns,
89
+ dateAdapter: _AdapterDateFnsV3.AdapterDateFns,
90
90
  children: /*#__PURE__*/ (0, _jsxruntime.jsxs)(_material.Stack, {
91
91
  spacing: 2,
92
92
  sx: (theme)=>({
@@ -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;