@perses-dev/dashboards 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/Panel/Panel.js +9 -3
- package/dist/cjs/components/Panel/Panel.test.js +1 -0
- package/dist/components/Panel/Panel.d.ts.map +1 -1
- package/dist/components/Panel/Panel.js +1 -1
- package/dist/components/Panel/Panel.test.d.ts +1 -1
- package/dist/components/Panel/Panel.test.d.ts.map +1 -1
- package/dist/components/Panel/Panel.test.js +1 -1
- package/package.json +8 -4
|
@@ -18,11 +18,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
18
18
|
// See the License for the specific language governing permissions and
|
|
19
19
|
// limitations under the License.
|
|
20
20
|
const react_1 = require("react");
|
|
21
|
+
const use_resize_observer_1 = __importDefault(require("use-resize-observer"));
|
|
22
|
+
const react_intersection_observer_1 = require("react-intersection-observer");
|
|
21
23
|
const plugin_system_1 = require("@perses-dev/plugin-system");
|
|
22
24
|
const components_1 = require("@perses-dev/components");
|
|
23
25
|
const material_1 = require("@mui/material");
|
|
24
26
|
const InformationOutline_1 = __importDefault(require("mdi-material-ui/InformationOutline"));
|
|
25
|
-
const use_resize_observer_1 = __importDefault(require("use-resize-observer"));
|
|
26
27
|
/**
|
|
27
28
|
* Renders a PanelDefinition's content inside of a Card.
|
|
28
29
|
*/
|
|
@@ -35,9 +36,14 @@ function Panel(props) {
|
|
|
35
36
|
return undefined;
|
|
36
37
|
return { width, height };
|
|
37
38
|
}, [width, height]);
|
|
39
|
+
const { ref, inView } = (0, react_intersection_observer_1.useInView)({
|
|
40
|
+
threshold: 0.3,
|
|
41
|
+
initialInView: false,
|
|
42
|
+
triggerOnce: true,
|
|
43
|
+
});
|
|
38
44
|
// TODO: adjust padding for small panels, consistent way to determine isLargePanel here and in StatChart
|
|
39
45
|
const panelPadding = 1.5;
|
|
40
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Card, { sx: {
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Card, { ref: ref, sx: {
|
|
41
47
|
...others.sx,
|
|
42
48
|
width: '100%',
|
|
43
49
|
height: '100%',
|
|
@@ -59,6 +65,6 @@ function Panel(props) {
|
|
|
59
65
|
':last-child': {
|
|
60
66
|
padding: (theme) => theme.spacing(panelPadding),
|
|
61
67
|
},
|
|
62
|
-
}, ref: setContentElement, children: (0, jsx_runtime_1.jsx)(plugin_system_1.PluginBoundary, { loadingFallback: "Loading...", ErrorFallbackComponent: components_1.ErrorAlert, children: (0, jsx_runtime_1.jsx)(plugin_system_1.PanelComponent, { definition: definition, contentDimensions: contentDimensions }) }) })] }));
|
|
68
|
+
}, ref: setContentElement, children: (0, jsx_runtime_1.jsx)(plugin_system_1.PluginBoundary, { loadingFallback: "Loading...", ErrorFallbackComponent: components_1.ErrorAlert, children: inView === true && (0, jsx_runtime_1.jsx)(plugin_system_1.PanelComponent, { definition: definition, contentDimensions: contentDimensions }) }) })] }));
|
|
63
69
|
}
|
|
64
70
|
exports.Panel = Panel;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
const plugin_system_1 = require("@perses-dev/plugin-system");
|
|
5
|
+
require("intersection-observer");
|
|
5
6
|
const react_1 = require("@testing-library/react");
|
|
6
7
|
const test_1 = require("../../test");
|
|
7
8
|
const Panel_1 = require("./Panel");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Panel.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.tsx"],"names":[],"mappings":";AAkBA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAa,SAAS,EAAuC,MAAM,eAAe,CAAC;AAG1F,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,UAAU,EAAE,eAAe,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,eA2FtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useState,useMemo}from"react";import{PluginBoundary,PanelComponent}from"@perses-dev/plugin-system";import{ErrorAlert,InfoTooltip,TooltipPlacement}from"@perses-dev/components";import{Box,Card,CardHeader,CardContent,Typography}from"@mui/material";import InformationOutlineIcon from"mdi-material-ui/InformationOutline";
|
|
1
|
+
import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useState,useMemo}from"react";import useResizeObserver from"use-resize-observer";import{useInView}from"react-intersection-observer";import{PluginBoundary,PanelComponent}from"@perses-dev/plugin-system";import{ErrorAlert,InfoTooltip,TooltipPlacement}from"@perses-dev/components";import{Box,Card,CardHeader,CardContent,Typography}from"@mui/material";import InformationOutlineIcon from"mdi-material-ui/InformationOutline";export function Panel(e){const{definition:i,...o}=e,[r,n]=useState(null),{width:t,height:s}=useResizeObserver({ref:r}),a=useMemo((()=>{if(void 0!==t&&void 0!==s)return{width:t,height:s}}),[t,s]),{ref:l,inView:d}=useInView({threshold:.3,initialInView:!1,triggerOnce:!0});return _jsxs(Card,{ref:l,sx:{...o.sx,width:"100%",height:"100%",display:"flex",flexFlow:"column nowrap"},variant:"outlined",...o,children:[_jsx(CardHeader,{title:_jsxs(Box,{sx:{display:"flex",alignItems:"center"},children:[_jsx(Typography,{component:"h2",variant:"body2",fontWeight:e=>e.typography.fontWeightMedium,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",children:i.display.name}),i.display.description&&_jsx(InfoTooltip,{id:"info-tooltip",description:i.display.description,placement:TooltipPlacement.Right,children:_jsx(InformationOutlineIcon,{"aria-describedby":"info-tooltip","aria-hidden":!1,sx:{fontSize:"1rem",position:"relative",left:"4px",cursor:"pointer"}})})]}),sx:{display:"block",padding:e=>e.spacing(1,1.5),borderBottom:e=>`solid 1px ${e.palette.divider}`}}),_jsx(CardContent,{sx:{position:"relative",overflow:"hidden",flexGrow:1,padding:e=>e.spacing(1.5),":last-child":{padding:e=>e.spacing(1.5)}},ref:n,children:_jsx(PluginBoundary,{loadingFallback:"Loading...",ErrorFallbackComponent:ErrorAlert,children:!0===d&&_jsx(PanelComponent,{definition:i,contentDimensions:a})})})]})}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import 'intersection-observer';
|
|
2
2
|
//# sourceMappingURL=Panel.test.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Panel.test.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.test.tsx"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"Panel.test.d.ts","sourceRoot":"","sources":["../../../src/components/Panel/Panel.test.tsx"],"names":[],"mappings":"AAeA,OAAO,uBAAuB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as _jsx}from"react/jsx-runtime";import{PluginRegistry}from"@perses-dev/plugin-system";import{screen}from"@testing-library/react";import{renderWithContext,mockPluginRegistryProps}from"../../test";import{Panel}from"./Panel";const FAKE_PANEL_PLUGIN={pluginType:"Panel",kind:"FakePanel",plugin:{PanelComponent:()=>_jsx("div",{role:"figure",children:"FakePanel chart"})}};describe("Panel",(()=>{let e;beforeEach((()=>{e={definition:{display:{name:"Fake Panel",description:"This is a fake panel"},kind:"FakePanel",options:{}}}})),it("should render name and info icon",(async()=>{(()=>{const{addMockPlugin:n,pluginRegistryProps:i}=mockPluginRegistryProps();n(FAKE_PANEL_PLUGIN),renderWithContext(_jsx(PluginRegistry,{...i,children:_jsx(Panel,{...e})}))})(),await screen.findByText("Fake Panel"),screen.queryByLabelText("info-tooltip")}))}));
|
|
1
|
+
import{jsx as _jsx}from"react/jsx-runtime";import{PluginRegistry}from"@perses-dev/plugin-system";import"intersection-observer";import{screen}from"@testing-library/react";import{renderWithContext,mockPluginRegistryProps}from"../../test";import{Panel}from"./Panel";const FAKE_PANEL_PLUGIN={pluginType:"Panel",kind:"FakePanel",plugin:{PanelComponent:()=>_jsx("div",{role:"figure",children:"FakePanel chart"})}};describe("Panel",(()=>{let e;beforeEach((()=>{e={definition:{display:{name:"Fake Panel",description:"This is a fake panel"},kind:"FakePanel",options:{}}}})),it("should render name and info icon",(async()=>{(()=>{const{addMockPlugin:n,pluginRegistryProps:i}=mockPluginRegistryProps();n(FAKE_PANEL_PLUGIN),renderWithContext(_jsx(PluginRegistry,{...i,children:_jsx(Panel,{...e})}))})(),await screen.findByText("Fake Panel"),screen.queryByLabelText("info-tooltip")}))}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@perses-dev/dashboards",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "The dashboards feature in Perses",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/perses/perses/blob/main/README.md",
|
|
@@ -24,13 +24,17 @@
|
|
|
24
24
|
"lint:fix": "eslint --fix src --ext .ts,.tsx"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@perses-dev/components": "^0.5.
|
|
28
|
-
"@perses-dev/core": "^0.5.
|
|
29
|
-
"@perses-dev/plugin-system": "^0.5.
|
|
27
|
+
"@perses-dev/components": "^0.5.2",
|
|
28
|
+
"@perses-dev/core": "^0.5.2",
|
|
29
|
+
"@perses-dev/plugin-system": "^0.5.2",
|
|
30
30
|
"immer": "^9.0.15",
|
|
31
|
+
"react-intersection-observer": "^9.4.0",
|
|
31
32
|
"use-immer": "^0.7.0",
|
|
32
33
|
"use-resize-observer": "^8.0.0"
|
|
33
34
|
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"intersection-observer": "^0.12.2"
|
|
37
|
+
},
|
|
34
38
|
"peerDependencies": {
|
|
35
39
|
"@mui/material": "^5.5.1",
|
|
36
40
|
"react": "^17.0.2"
|